sync_issues 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sync_issues/comparison.rb +37 -0
- data/lib/sync_issues/github.rb +2 -3
- data/lib/sync_issues/synchronizer.rb +7 -6
- data/lib/sync_issues/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd67c4c0bb708d7b393d620da1a325d0af3cb1bc
|
4
|
+
data.tar.gz: bc62f99652b3bc6ca0c01c1cf157a0687a3e9bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1be77f29065be111b5334bf17f0833298ce09865953cf5d841b0f5ccea60ab5d3e6e984b455ff09d02b90307147defa5db20b462cb5ef1c1ece0bb6511c5c61
|
7
|
+
data.tar.gz: 2b93b1d43ed7d83adfb0caf8576ed09c0d74e8ed3c8a50649b7a967b48b1d4098df1d50b4cc3e3de8c5c032899b32bb2a82142c1c688d486b5fa92a7763d6a51
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'error'
|
2
|
+
|
3
|
+
module SyncIssues
|
4
|
+
# Comparison represents differences between Issues (local and GitHub)
|
5
|
+
class Comparison
|
6
|
+
attr_reader :changed, :content, :title
|
7
|
+
|
8
|
+
def initialize(issue, github_issue)
|
9
|
+
@changed = []
|
10
|
+
@content = github_issue.body
|
11
|
+
@title = github_issue.title
|
12
|
+
compare(issue, github_issue)
|
13
|
+
end
|
14
|
+
|
15
|
+
def changed?
|
16
|
+
!@changed.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def compare(issue, github_issue)
|
22
|
+
unless issue.new_title.nil?
|
23
|
+
@changed << 'title'
|
24
|
+
@title = issue.new_title
|
25
|
+
end
|
26
|
+
unless content_matches?(issue.content, github_issue.body)
|
27
|
+
@changed << 'body'
|
28
|
+
@content = issue.content
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def content_matches?(first, second)
|
33
|
+
second.delete!("\r")
|
34
|
+
first.gsub(/\[x\]/, '[ ]') == second.gsub(/\[x\]/, '[ ]')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/sync_issues/github.rb
CHANGED
@@ -25,9 +25,8 @@ module SyncIssues
|
|
25
25
|
raise Error, 'repository not found'
|
26
26
|
end
|
27
27
|
|
28
|
-
def update_issue(repository,
|
29
|
-
@client.update_issue(repository.full_name,
|
30
|
-
issue.new_title || issue.title, issue.content)
|
28
|
+
def update_issue(repository, issue_number, title, content)
|
29
|
+
@client.update_issue(repository.full_name, issue_number, title, content)
|
31
30
|
end
|
32
31
|
|
33
32
|
private
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'comparison'
|
1
2
|
require_relative 'error'
|
2
3
|
require_relative 'parser'
|
3
4
|
require 'English'
|
@@ -85,13 +86,13 @@ module SyncIssues
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def update_issue(repository, issue, github_issue)
|
88
|
-
|
89
|
-
|
90
|
-
changed << 'body' unless issue.content == github_issue.body
|
91
|
-
return if changed.empty?
|
89
|
+
comparison = Comparison.new(issue, github_issue)
|
90
|
+
return unless comparison.changed?
|
92
91
|
|
93
|
-
|
94
|
-
|
92
|
+
changed = comparison.changed.join(', ')
|
93
|
+
puts "Updating #{changed} on ##{github_issue.number}"
|
94
|
+
SyncIssues.github.update_issue(repository, github_issue.number,
|
95
|
+
comparison.title, comparison.content)
|
95
96
|
end
|
96
97
|
end
|
97
98
|
end
|
data/lib/sync_issues/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sync_issues
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Boe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- bin/sync_issues
|
67
67
|
- lib/sync_issues.rb
|
68
68
|
- lib/sync_issues/command.rb
|
69
|
+
- lib/sync_issues/comparison.rb
|
69
70
|
- lib/sync_issues/error.rb
|
70
71
|
- lib/sync_issues/github.rb
|
71
72
|
- lib/sync_issues/issue.rb
|