sync_issues 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9a86463a72523cc3da204c2be3cb67ababb8dfc
4
- data.tar.gz: d08f2187e85282b976b4e7c9f506a5a8dc2df475
3
+ metadata.gz: 77f59d92db9bb219cd1ff88a3914d4b9fea5e917
4
+ data.tar.gz: f454013652d08bc68ec38a74172741e451a62db0
5
5
  SHA512:
6
- metadata.gz: 2eef9c97d166350c79b265d7af1ee869faf99a73242ca01a865f37d0f2bc4240f241edbe2ffb5d04bef0fa4f26bc784b2bc4521e8e87114dadcc2152dec8d15d
7
- data.tar.gz: e38af6793db30c7f58ddd6b1b3d3ba8b34d69e940c0e7979c1fec2ee010ddc6ee3ffd01d48bc54c657845e3851f2fa773d539a1f1f3b4180bc4e5523ca97af1d
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
+ ![Generate Access Token](img/access_token_generate.png)
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
+ ![New Access Token](img/access_token_new.png)
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
- sync_tasks /path/to/tasks/directory bboe/repo1 appfolio/repo2
43
+ sync_issues /path/to/tasks/directory bboe/repo1 appfolio/repo2
18
44
 
19
45
 
20
46
  ## Local Issue Directory
@@ -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 Error => exc
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(msg, condition = true)
38
- puts msg
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
 
@@ -7,4 +7,7 @@ module SyncIssues
7
7
 
8
8
  class ParseError < Error
9
9
  end
10
+
11
+ class TokenError < Error
12
+ end
10
13
  end
@@ -33,7 +33,10 @@ module SyncIssues
33
33
 
34
34
  def token
35
35
  path = File.expand_path('~/.config/sync_issues.yaml')
36
- SafeYAML.load(File.read(path))['token']
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
- SyncIssues.github.repository(repository_name)
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
- SyncIssues.github.issues(repository.full_name).each do |issue|
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
- SyncIssues.github.create_issue(repository, issue)
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
- SyncIssues.github.update_issue(repository, github_issue.number,
95
- comparison.title, comparison.content)
95
+ @github.update_issue(repository, github_issue.number, comparison.title,
96
+ comparison.content)
96
97
  end
97
98
  end
98
99
  end
@@ -1,4 +1,4 @@
1
1
  # SyncIssues
2
2
  module SyncIssues
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
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.1.1
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-04 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt