sync_github_forks 0.0.2 → 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_github_forks/cli.rb +23 -2
- data/lib/sync_github_forks/ctrl.rb +16 -1
- data/lib/sync_github_forks/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2d14e05799f51ef57b95ccd7bf93015dcc826eb
|
4
|
+
data.tar.gz: 8a8a912e104d6b3e0c17cb67d91c0fa9bfd1430e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7adffeaec1592b920fd5b825264b62a926857878cfd599a7d9c4c3d6fe9365014511d154a94763d0e053c29ca1746426cb346df2b03e4f0f259826773e3f03a4
|
7
|
+
data.tar.gz: 6f99e8bead74d46c463e7fbf6b4a6c0eea067b0807771d3ebe188f9a645e071487887995fae663fa638ac53cba380b63a23f55df4dc8a5a2ea2ba6400801ec66
|
@@ -40,12 +40,22 @@ class SyncGithubForks::Cli
|
|
40
40
|
options = OpenStruct.new
|
41
41
|
options.config_file = nil
|
42
42
|
options.github_token = nil
|
43
|
+
options.repo = nil
|
44
|
+
options.list = false
|
43
45
|
|
44
46
|
OptionParser.new do |opts|
|
45
47
|
opts.on('-c', '--config FILE', 'Use FILE as the configuration file') do |file|
|
46
48
|
options.config_file = file
|
47
49
|
end
|
48
50
|
|
51
|
+
opts.on('-l', '--list', 'List all repos in the configuration file') do
|
52
|
+
options.list = true
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on('-r', '--repo REPO', 'Update only REPO from the configuration file') do |repo|
|
56
|
+
options.repo = repo.strip
|
57
|
+
end
|
58
|
+
|
49
59
|
opts.on('-t', '--github_token TOKEN', 'Your GitHub Access Token',
|
50
60
|
'Default: GITHUB_ACCESS_TOKEN environment variable'
|
51
61
|
) do |token|
|
@@ -57,7 +67,7 @@ class SyncGithubForks::Cli
|
|
57
67
|
puts opts
|
58
68
|
exit
|
59
69
|
end
|
60
|
-
end
|
70
|
+
end.parse!
|
61
71
|
|
62
72
|
# Set option defaults
|
63
73
|
|
@@ -78,6 +88,13 @@ class SyncGithubForks::Cli
|
|
78
88
|
exit 1
|
79
89
|
end
|
80
90
|
|
91
|
+
if options.repo
|
92
|
+
unless options.config.keys.include?(options.repo)
|
93
|
+
$stderr.puts("ERROR: Could not find specified repo '#{options.repo}' in '#{options.config_file}'")
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
81
98
|
## GitHub Token
|
82
99
|
unless options.github_token
|
83
100
|
options.github_token = ENV['GITHUB_ACCESS_TOKEN']
|
@@ -88,7 +105,11 @@ class SyncGithubForks::Cli
|
|
88
105
|
exit 1
|
89
106
|
end
|
90
107
|
|
91
|
-
|
108
|
+
if options.list
|
109
|
+
SyncGithubForks::Ctrl.list(options)
|
110
|
+
else
|
111
|
+
SyncGithubForks::Ctrl.sync(options)
|
112
|
+
end
|
92
113
|
|
93
114
|
return 0
|
94
115
|
end
|
@@ -1,4 +1,15 @@
|
|
1
1
|
module SyncGithubForks::Ctrl
|
2
|
+
def self.list(options)
|
3
|
+
repo_list = options.config.keys
|
4
|
+
|
5
|
+
if repo_list.empty?
|
6
|
+
puts "No repositories found in '#{options.config_file}'"
|
7
|
+
else
|
8
|
+
puts "Repos in '#{options.config_file}'"
|
9
|
+
puts %( * #{repo_list.sort.join("\n * ")})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
2
13
|
def self.sync(options)
|
3
14
|
require 'tmpdir'
|
4
15
|
require 'octokit'
|
@@ -8,7 +19,11 @@ module SyncGithubForks::Ctrl
|
|
8
19
|
Octokit.auto_paginate = true
|
9
20
|
client = Octokit::Client.new(:access_token => options.github_token)
|
10
21
|
|
11
|
-
|
22
|
+
if options.repo
|
23
|
+
forked_repos = { options.repo => options.config[options.repo] }
|
24
|
+
else
|
25
|
+
forked_repos = options.config
|
26
|
+
end
|
12
27
|
|
13
28
|
forked_repos.keys.sort.each do |repo_name|
|
14
29
|
repo = client.repo(repo_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sync_github_forks
|
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
|
- Trevor Vaughan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
requirements:
|
127
127
|
- GitHub OctoKit
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.6.
|
129
|
+
rubygems_version: 2.6.13
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: A simple tool for synchronizing GitHub forked repositories
|