sync_issues 0.1.1 → 0.2.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/README.md +27 -1
- data/lib/sync_issues/command.rb +7 -3
- data/lib/sync_issues/error.rb +3 -0
- data/lib/sync_issues/github.rb +4 -1
- data/lib/sync_issues/synchronizer.rb +6 -5
- data/lib/sync_issues/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77f59d92db9bb219cd1ff88a3914d4b9fea5e917
|
4
|
+
data.tar.gz: f454013652d08bc68ec38a74172741e451a62db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 517e439aec314cbd00a20bd268e02b1254352f8cf112eb284b8cbcc7e71c12cc50516d851c7122ad830a9bdd0aabd261f66a377f57a6ffe9d10e43f8990edc4b
|
7
|
+
data.tar.gz: 60af37b8b814bffea5db9d38d1e27dcde4b907cfccc35999d0ca9f944783fdacf8ad070b80612c6c1d6a3e0542e1d0531067f98ccc2338a39dd002262524faa3
|
data/README.md
CHANGED
@@ -10,11 +10,37 @@ To install sync_issues run:
|
|
10
10
|
|
11
11
|
gem install sync_issues
|
12
12
|
|
13
|
+
|
14
|
+
## sync_issues.yaml configuration
|
15
|
+
|
16
|
+
In order to run sync_issues you will need to create a GitHub API token with the
|
17
|
+
`public_repo` scope for creating issues only on public repositories, or the
|
18
|
+
`repo` scope for creating issues on both private and public repositories.
|
19
|
+
|
20
|
+

|
21
|
+
|
22
|
+
To create a token visit https://github.com/settings/tokens/new, and select the
|
23
|
+
appropriate scope `repo` or `public_repo` for your projects. Then click the
|
24
|
+
green "Generate Token" button to create the token.
|
25
|
+
|
26
|
+

|
27
|
+
|
28
|
+
Create a config file `$HOME/.config/sync_issues.yaml` with the following
|
29
|
+
contents ensuring that you use the access token generated for you:
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
token: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
|
33
|
+
```
|
34
|
+
|
35
|
+
If you lose the page with your new access token before creating
|
36
|
+
`sync_issues.yaml`, don't fret. Delete the appropriate token, and try again.
|
37
|
+
|
38
|
+
|
13
39
|
## Running sync_issues
|
14
40
|
|
15
41
|
Run sync_issues via:
|
16
42
|
|
17
|
-
|
43
|
+
sync_issues /path/to/tasks/directory bboe/repo1 appfolio/repo2
|
18
44
|
|
19
45
|
|
20
46
|
## Local Issue Directory
|
data/lib/sync_issues/command.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'docopt'
|
2
|
+
require 'octokit'
|
2
3
|
require_relative 'error'
|
3
4
|
require_relative 'synchronizer'
|
4
5
|
require_relative 'version'
|
@@ -28,14 +29,17 @@ module SyncIssues
|
|
28
29
|
handle_args(Docopt.docopt(DOC, version: VERSION))
|
29
30
|
rescue Docopt::Exit => exc
|
30
31
|
exit_with_status(exc.message, exc.class.usage != '')
|
31
|
-
rescue
|
32
|
+
rescue TokenError => exc
|
33
|
+
exit_with_status("#{exc.message}\nPlease see:
|
34
|
+
https://github.com/bboe/sync_issues#sync_issuesyaml-configuration")
|
35
|
+
rescue Error, Octokit::Unauthorized => exc
|
32
36
|
exit_with_status(exc.message)
|
33
37
|
end
|
34
38
|
|
35
39
|
private
|
36
40
|
|
37
|
-
def exit_with_status(
|
38
|
-
puts
|
41
|
+
def exit_with_status(message, condition = true)
|
42
|
+
puts message
|
39
43
|
@exit_status == 0 && condition ? 1 : @exit_status
|
40
44
|
end
|
41
45
|
|
data/lib/sync_issues/error.rb
CHANGED
data/lib/sync_issues/github.rb
CHANGED
@@ -33,7 +33,10 @@ module SyncIssues
|
|
33
33
|
|
34
34
|
def token
|
35
35
|
path = File.expand_path('~/.config/sync_issues.yaml')
|
36
|
-
|
36
|
+
raise TokenError, "#{path} does not exist" unless File.exist?(path)
|
37
|
+
SafeYAML.load(File.read(path))['token'].tap do |token|
|
38
|
+
raise TokenError, "#{path} missing token attribute" if token.nil?
|
39
|
+
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -7,6 +7,7 @@ module SyncIssues
|
|
7
7
|
# Synchronizer is responsible for the actual synchronization.
|
8
8
|
class Synchronizer
|
9
9
|
def initialize(directory, repository_names, update_only: false)
|
10
|
+
@github = SyncIssues.github
|
10
11
|
@issues = issues(directory)
|
11
12
|
@repositories = repositories(repository_names)
|
12
13
|
@update_only = update_only
|
@@ -45,7 +46,7 @@ module SyncIssues
|
|
45
46
|
def repositories(repository_names)
|
46
47
|
repositories = repository_names.map do |repository_name|
|
47
48
|
begin
|
48
|
-
|
49
|
+
@github.repository(repository_name)
|
49
50
|
rescue Error => exc
|
50
51
|
puts "'#{repository_name}' #{exc}"
|
51
52
|
nil
|
@@ -61,7 +62,7 @@ module SyncIssues
|
|
61
62
|
puts "Repository: #{repository.full_name}"
|
62
63
|
|
63
64
|
existing_by_title = {}
|
64
|
-
|
65
|
+
@github.issues(repository.full_name).each do |issue|
|
65
66
|
existing_by_title[issue.title] = issue
|
66
67
|
end
|
67
68
|
|
@@ -81,7 +82,7 @@ module SyncIssues
|
|
81
82
|
puts "Skipping create issue: #{issue.title}"
|
82
83
|
else
|
83
84
|
puts "Adding issue: #{issue.title}"
|
84
|
-
|
85
|
+
@github.create_issue(repository, issue)
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
@@ -91,8 +92,8 @@ module SyncIssues
|
|
91
92
|
|
92
93
|
changed = comparison.changed.join(', ')
|
93
94
|
puts "Updating #{changed} on ##{github_issue.number}"
|
94
|
-
|
95
|
-
|
95
|
+
@github.update_issue(repository, github_issue.number, comparison.title,
|
96
|
+
comparison.content)
|
96
97
|
end
|
97
98
|
end
|
98
99
|
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.
|
4
|
+
version: 0.2.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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|