git-multi 1.0.5 → 1.0.6
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/.pryrc +5 -5
- data/.rubocop.yml +30 -1
- data/Rakefile +7 -3
- data/contrib/git-dash/git-dash.rb +8 -3
- data/exe/git-multi +1 -1
- data/git-multi.gemspec +1 -0
- data/lib/ext/commify.rb +1 -1
- data/lib/ext/dir.rb +4 -4
- data/lib/ext/kernel.rb +5 -0
- data/lib/ext/notify.rb +1 -1
- data/lib/ext/sawyer/resource.rb +3 -1
- data/lib/ext/string.rb +11 -7
- data/lib/git/hub.rb +14 -10
- data/lib/git/multi/commands.rb +29 -34
- data/lib/git/multi/gemspec.rb +19 -0
- data/lib/git/multi/settings.rb +28 -26
- data/lib/git/multi/utils.rb +53 -0
- data/lib/git/multi/version.rb +11 -28
- data/lib/git/multi.rb +15 -14
- data/man/git-multi.1 +3 -3
- data/man/git-multi.html +2 -2
- metadata +5 -3
- data/lib/ext/utils.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49bfee3e9faa4d3eea798863ec6891761b5f2dc144912437f8aed41f4ef3afc4
|
4
|
+
data.tar.gz: e35b5abff76ddc7f394f1b0e35a3479bd6a365f16861e39111a70a1f8f95fd13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a5a8d752b0c9ff87f3764f60bd83ea13ff293b1ad0fbf3a5d4e029e00423e438916242093fddbdc3d98092efd34f40f6166ffec2b629bdc6cd17c97c300e95
|
7
|
+
data.tar.gz: 503dd9d963fedc4c1d629ae1db81e79caad4274f5f5d4bdf600e8679e36c1dfd2fdd374da57dca193f94a3b6224af318b6e546ccea9632e6ea31bf0346edcd33
|
data/.pryrc
CHANGED
@@ -16,10 +16,10 @@ require 'octokit'
|
|
16
16
|
Octokit.middleware.response :logger, logger
|
17
17
|
|
18
18
|
# enumerator for Faraday middleware apps
|
19
|
-
def (
|
19
|
+
def (_middleware = Octokit.middleware).each_app
|
20
20
|
Enumerator.new do |yielder|
|
21
21
|
next_app = app
|
22
|
-
while next_app
|
22
|
+
while next_app
|
23
23
|
yielder << next_app
|
24
24
|
next_app = next_app.instance_variable_get(:@app)
|
25
25
|
end
|
@@ -28,12 +28,12 @@ end
|
|
28
28
|
|
29
29
|
# utility function to set pry context
|
30
30
|
# to an instance of <Octokit::Client>
|
31
|
-
def client() pry Git::Hub.send(:client)
|
31
|
+
def client() pry Git::Hub.send(:client); end
|
32
32
|
|
33
33
|
# utility function to set pry context
|
34
34
|
# to the Array of github repositories
|
35
|
-
def repos() pry Git::Multi.repositories
|
35
|
+
def repos() pry Git::Multi.repositories; end
|
36
36
|
|
37
37
|
# utility function to set pry context
|
38
38
|
# to the various 'git multi' commands:
|
39
|
-
def cmds() pry Git::Multi::Commands
|
39
|
+
def cmds() pry Git::Multi::Commands; end
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,33 @@
|
|
1
|
-
|
1
|
+
Layout/EmptyLinesAroundClassBody:
|
2
|
+
Enabled: false
|
3
|
+
Layout/EmptyLinesAroundModuleBody:
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
Lint/HandleExceptions:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
2
10
|
Enabled: false
|
11
|
+
Metrics/LineLength:
|
12
|
+
Enabled: false
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Enabled: false
|
15
|
+
Metrics/ModuleLength:
|
16
|
+
Enabled: false
|
17
|
+
|
3
18
|
Style/BlockDelimiters:
|
4
19
|
Enabled: false
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false
|
22
|
+
Style/FrozenStringLiteralComment:
|
23
|
+
Enabled: false
|
24
|
+
Style/Lambda:
|
25
|
+
Enabled: false
|
26
|
+
Style/NestedTernaryOperator:
|
27
|
+
Enabled: false
|
28
|
+
Style/SingleLineMethods:
|
29
|
+
Enabled: false
|
30
|
+
Style/TrailingCommaInArguments:
|
31
|
+
Enabled: false
|
32
|
+
Style/TrailingCommaInLiteral:
|
33
|
+
Enabled: false
|
data/Rakefile
CHANGED
@@ -15,6 +15,10 @@ task :validate do
|
|
15
15
|
gemspec.validate
|
16
16
|
end
|
17
17
|
|
18
|
+
require 'rubocop/rake_task'
|
19
|
+
|
20
|
+
RuboCop::RakeTask.new
|
21
|
+
|
18
22
|
require 'rake/testtask'
|
19
23
|
|
20
24
|
Rake::TestTask.new(:test) do |t|
|
@@ -23,7 +27,7 @@ Rake::TestTask.new(:test) do |t|
|
|
23
27
|
t.test_files = FileList['test/**/*_test.rb']
|
24
28
|
end
|
25
29
|
|
26
|
-
task :default => :test
|
30
|
+
task :default => [:rubocop, :test]
|
27
31
|
|
28
32
|
require 'git/multi'
|
29
33
|
|
@@ -41,8 +45,8 @@ end
|
|
41
45
|
|
42
46
|
task :documentation => git_asciidoc do
|
43
47
|
Dir.chdir(documentation) do
|
44
|
-
# use git's documentation
|
45
|
-
|
48
|
+
# use git's documentation framework
|
49
|
+
`make git-multi.1 git-multi.html`
|
46
50
|
FileUtils.cp 'git-multi.1', Git::Multi::MAN_PAGE
|
47
51
|
FileUtils.cp 'git-multi.html', Git::Multi::HTML_PAGE
|
48
52
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# rubocop:disable all
|
4
|
+
|
3
5
|
TIME_INTERVALS = {
|
4
6
|
|
5
7
|
:minute => ( MINUTE = 60 ), # seconds
|
@@ -50,9 +52,11 @@ RED = {
|
|
50
52
|
:year => "#FF2222" ,
|
51
53
|
}.freeze
|
52
54
|
|
53
|
-
|
55
|
+
# rubocop:enable all
|
56
|
+
|
57
|
+
if $PROGRAM_NAME == __FILE__
|
54
58
|
|
55
|
-
|
59
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __dir__)
|
56
60
|
|
57
61
|
require 'git/multi'
|
58
62
|
|
@@ -64,6 +68,7 @@ if __FILE__ == $0
|
|
64
68
|
def project.age_in_seconds
|
65
69
|
(Time.now - pushed_at).to_i
|
66
70
|
end
|
71
|
+
|
67
72
|
def project.age_in_words
|
68
73
|
time_distance_in_words(age_in_seconds)
|
69
74
|
end
|
@@ -75,7 +80,7 @@ if __FILE__ == $0
|
|
75
80
|
require 'erb'
|
76
81
|
|
77
82
|
# generate HTML page with a dashboard of global GitHub repository activity:
|
78
|
-
puts ERB.new(File.read(File.join(__dir__,
|
83
|
+
puts ERB.new(File.read(File.join(__dir__, 'git-dash.erb'))).result(binding)
|
79
84
|
|
80
85
|
end
|
81
86
|
|
data/exe/git-multi
CHANGED
data/git-multi.gemspec
CHANGED
data/lib/ext/commify.rb
CHANGED
data/lib/ext/dir.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class Dir
|
2
2
|
def git_repos(subdir = '*')
|
3
|
-
Dir.glob(File.join(
|
4
|
-
path_to_git_repo = File.dirname(path_to_git_dir)
|
5
|
-
repo_name = path_to_git_repo[
|
6
|
-
def repo_name.full_name() self
|
3
|
+
Dir.glob(File.join(path, subdir, '*', '.git')).map { |path_to_git_dir|
|
4
|
+
path_to_git_repo = File.dirname(path_to_git_dir) # without "/.git"
|
5
|
+
repo_name = path_to_git_repo[%r{[^\/]+\/[^\/]+\z}] # e.g. "pvdb/git-multi"
|
6
|
+
def repo_name.full_name() self; end
|
7
7
|
repo_name
|
8
8
|
}
|
9
9
|
end
|
data/lib/ext/kernel.rb
ADDED
data/lib/ext/notify.rb
CHANGED
@@ -13,7 +13,7 @@ def notify(message, options = {}, verbose = false)
|
|
13
13
|
# send a given message to the Mac OS X Notification Center
|
14
14
|
# but only if the git-multi script is running interactively
|
15
15
|
# and if the "terminal-notifier" gem has been installed...
|
16
|
-
|
16
|
+
interactive? && defined?(TerminalNotifier) && begin
|
17
17
|
options[:title] ||= 'git-multi'
|
18
18
|
TerminalNotifier.notify(message, options, verbose)
|
19
19
|
end
|
data/lib/ext/sawyer/resource.rb
CHANGED
data/lib/ext/string.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
+
# rubocop:disable Layout/EmptyLineBetweenDefs
|
2
|
+
|
1
3
|
class String
|
2
4
|
|
3
|
-
def colorize(color_code) "\e[#{color_code}m#{self}\e[0m"
|
5
|
+
def colorize(color_code) "\e[#{color_code}m#{self}\e[0m"; end
|
4
6
|
|
5
|
-
def bold() colorize('1')
|
6
|
-
def invert() colorize('7')
|
7
|
+
def bold() colorize('1'); end
|
8
|
+
def invert() colorize('7'); end
|
7
9
|
|
8
|
-
def red() colorize('31')
|
9
|
-
def blue() colorize('34')
|
10
|
-
def green() colorize('32')
|
10
|
+
def red() colorize('31'); end
|
11
|
+
def blue() colorize('34'); end
|
12
|
+
def green() colorize('32'); end
|
11
13
|
|
12
|
-
def undent() gsub(/^.{#{slice(/^ +/).length}}/, '')
|
14
|
+
def undent() gsub(/^.{#{slice(/^ +/).length}}/, ''); end
|
13
15
|
|
14
16
|
end
|
17
|
+
|
18
|
+
# rubocop:enable Layout/EmptyLineBetweenDefs
|
data/lib/git/hub.rb
CHANGED
@@ -21,8 +21,8 @@ module Git
|
|
21
21
|
|
22
22
|
def client
|
23
23
|
@client ||= Octokit::Client.new(
|
24
|
-
:
|
25
|
-
:
|
24
|
+
access_token: Git::Multi::TOKEN,
|
25
|
+
auto_paginate: true,
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
@@ -39,7 +39,7 @@ module Git
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
# FIXME update login as part of `--refresh`
|
42
|
+
# FIXME: update login as part of `--refresh`
|
43
43
|
|
44
44
|
def login
|
45
45
|
@login ||= begin
|
@@ -49,7 +49,7 @@ module Git
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# FIXME update orgs as part of `--refresh`
|
52
|
+
# FIXME: update orgs as part of `--refresh`
|
53
53
|
|
54
54
|
def orgs
|
55
55
|
@orgs ||= begin
|
@@ -78,12 +78,14 @@ module Git
|
|
78
78
|
@user_repositories = Hash.new { |repos, (user, type)|
|
79
79
|
repos[[user, type]] = begin
|
80
80
|
notify("Refreshing #{type} '#{user}' repositories from GitHub")
|
81
|
-
client
|
82
|
-
|
81
|
+
client
|
82
|
+
.repositories(user, type: type)
|
83
|
+
.sort_by { |repo| repo[:name].downcase }
|
83
84
|
end
|
84
85
|
}
|
85
86
|
|
86
|
-
def user_repositories(user, type = :owner)
|
87
|
+
def user_repositories(user, type = :owner)
|
88
|
+
# type can be one of: all, owner, member
|
87
89
|
@user_repositories[[user, type]]
|
88
90
|
end
|
89
91
|
|
@@ -94,12 +96,14 @@ module Git
|
|
94
96
|
@org_repositories = Hash.new { |repos, (org, type)|
|
95
97
|
repos[[org, type]] = begin
|
96
98
|
notify("Refreshing #{type} '#{org}' repositories from GitHub")
|
97
|
-
client
|
98
|
-
|
99
|
+
client
|
100
|
+
.org_repositories(org, type: type)
|
101
|
+
.sort_by { |repo| repo[:name].downcase }
|
99
102
|
end
|
100
103
|
}
|
101
104
|
|
102
|
-
def org_repositories(org, type = :owner)
|
105
|
+
def org_repositories(org, type = :owner)
|
106
|
+
# type can be one of: all, public, private, forks, sources, member
|
103
107
|
@org_repositories[[org, type]]
|
104
108
|
end
|
105
109
|
|
data/lib/git/multi/commands.rb
CHANGED
@@ -28,9 +28,8 @@ module Git
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def report
|
31
|
-
|
32
|
-
notify(missing_repos.map(&:full_name), :
|
33
|
-
end
|
31
|
+
(missing_repos = Git::Multi.missing_repositories).any? &&
|
32
|
+
notify(missing_repos.map(&:full_name), subtitle: "#{missing_repos.count} missing repos")
|
34
33
|
end
|
35
34
|
|
36
35
|
def list
|
@@ -72,12 +71,12 @@ module Git
|
|
72
71
|
def count
|
73
72
|
# https://developer.github.com/v3/repos/#list-user-repositories
|
74
73
|
user = Git::Multi::USER
|
75
|
-
%w
|
74
|
+
%w[all owner member].each { |type|
|
76
75
|
puts ["#{user}/#{type}", Git::Hub.user_repositories(user, type).count].join("\t")
|
77
76
|
}
|
78
77
|
# https://developer.github.com/v3/repos/#list-organization-repositories
|
79
|
-
|
80
|
-
%w
|
78
|
+
Git::Multi::ORGANIZATIONS.each do |org|
|
79
|
+
%w[all public private forks sources member].each { |type|
|
81
80
|
puts ["#{org}/#{type}", Git::Hub.org_repositories(org, type).count].join("\t")
|
82
81
|
}
|
83
82
|
end
|
@@ -102,12 +101,12 @@ module Git
|
|
102
101
|
->(project) {
|
103
102
|
Kernel.system "git clone -q #{project.rels[:ssh].href.shellescape}"
|
104
103
|
},
|
105
|
-
:
|
104
|
+
in: 'parent_dir'
|
106
105
|
)
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
110
|
-
def query
|
109
|
+
def query(args = [])
|
111
110
|
Git::Multi.repositories.each do |repo|
|
112
111
|
repo.just_do_it(
|
113
112
|
->(project) {
|
@@ -123,58 +122,54 @@ module Git
|
|
123
122
|
end
|
124
123
|
end
|
125
124
|
|
126
|
-
def system
|
127
|
-
args.map!(&:shellescape)
|
125
|
+
def system(args = [])
|
126
|
+
cmd = args.map!(&:shellescape).join(' ')
|
128
127
|
Git::Multi.cloned_repositories.each do |repo|
|
129
128
|
repo.just_do_it(
|
130
|
-
->(
|
131
|
-
Kernel.system
|
129
|
+
->(_project) {
|
130
|
+
Kernel.system cmd
|
132
131
|
},
|
133
132
|
->(project) {
|
134
|
-
Kernel.system "#{
|
133
|
+
Kernel.system "#{cmd} 2>&1 | sed -e 's#^##{project.full_name.shellescape}: #'"
|
135
134
|
},
|
136
|
-
:
|
135
|
+
in: 'local_path'
|
137
136
|
)
|
138
137
|
end
|
139
138
|
end
|
140
139
|
|
141
|
-
def raw
|
140
|
+
def raw(args)
|
142
141
|
args.unshift ['sh', '-c']
|
143
142
|
system args.flatten
|
144
143
|
end
|
145
144
|
|
146
|
-
def exec
|
145
|
+
def exec(command, args = [])
|
147
146
|
args.unshift ['git', '--no-pager', command]
|
148
147
|
system args.flatten
|
149
148
|
end
|
150
149
|
|
151
|
-
def find
|
150
|
+
def find(commands)
|
152
151
|
Git::Multi.cloned_repositories.each do |repo|
|
153
152
|
Dir.chdir(repo.local_path) do
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
)
|
160
|
-
end
|
161
|
-
rescue Octokit::NotFound
|
162
|
-
# project no longer exists on github.com
|
163
|
-
# consider running "git multi --stale"...
|
153
|
+
if repo.instance_eval(commands.join(' && '))
|
154
|
+
repo.just_do_it(
|
155
|
+
->(_project) { nil },
|
156
|
+
->(project) { puts project.full_name },
|
157
|
+
)
|
164
158
|
end
|
159
|
+
rescue Octokit::NotFound
|
160
|
+
# project no longer exists on github.com
|
161
|
+
# consider running "git multi --stale"...
|
165
162
|
end
|
166
163
|
end
|
167
164
|
end
|
168
165
|
|
169
|
-
def eval
|
166
|
+
def eval(commands)
|
170
167
|
Git::Multi.cloned_repositories.each do |repo|
|
171
168
|
Dir.chdir(repo.local_path) do
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
# consider running "git multi --stale"...
|
177
|
-
end
|
169
|
+
repo.instance_eval(commands.join(' ; '))
|
170
|
+
rescue Octokit::NotFound
|
171
|
+
# project no longer exists on github.com
|
172
|
+
# consider running "git multi --stale"...
|
178
173
|
end
|
179
174
|
end
|
180
175
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Git
|
2
|
+
module Multi
|
3
|
+
PIM = <<~"PIM".freeze # gem post_install_message, used in git-multi.gemspec
|
4
|
+
|
5
|
+
The required settings for \033[1mgit multi\33[0m are as follows:
|
6
|
+
|
7
|
+
\tgit config --global --add \033[1mgithub.user\033[0m <your_github_username>
|
8
|
+
\tgit config --global --add \033[1mgithub.organizations\033[0m <your_github_orgs>
|
9
|
+
\tgit config --global --add \033[1mgithub.token\033[0m <your_github_oauth_token>
|
10
|
+
|
11
|
+
Unless your top-level workarea is `${HOME}/Workarea` you should also set:
|
12
|
+
|
13
|
+
\tgit config --global --add \033[1mgit.multi.workarea\033[0m <your_root_workarea>
|
14
|
+
|
15
|
+
Thanks for using \033[1mgit multi\033[0m ... the ultimate multi-repo utility for git!
|
16
|
+
|
17
|
+
PIM
|
18
|
+
end
|
19
|
+
end
|
data/lib/git/multi/settings.rb
CHANGED
@@ -2,23 +2,25 @@ module Git
|
|
2
2
|
module Multi
|
3
3
|
module Settings
|
4
4
|
|
5
|
-
TICK = [
|
6
|
-
CROSS = [
|
7
|
-
ARROW = [
|
5
|
+
TICK = ['2714'.hex].pack('U*').green.freeze
|
6
|
+
CROSS = ['2718'.hex].pack('U*').red.freeze
|
7
|
+
ARROW = ['2794'.hex].pack('U*').blue.freeze
|
8
8
|
|
9
9
|
module_function
|
10
10
|
|
11
|
-
def setting_status
|
11
|
+
def setting_status(messages, valid, optional = false)
|
12
12
|
fields = messages.compact.join(' - ')
|
13
13
|
icon = valid ? TICK : optional ? ARROW : CROSS
|
14
|
-
if
|
15
|
-
print " #{fields}"
|
14
|
+
if interactive?
|
15
|
+
print " #{fields}"
|
16
|
+
sleep 0.66
|
17
|
+
puts "\x0d#{icon}"
|
16
18
|
else
|
17
19
|
puts "#{icon} #{fields}"
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
def file_status
|
23
|
+
def file_status(file, message = 'File')
|
22
24
|
setting_status(
|
23
25
|
[
|
24
26
|
message,
|
@@ -30,7 +32,7 @@ module Git
|
|
30
32
|
)
|
31
33
|
end
|
32
34
|
|
33
|
-
def directory_status
|
35
|
+
def directory_status(messages, directory)
|
34
36
|
setting_status(
|
35
37
|
messages,
|
36
38
|
directory && !directory.empty? && File.directory?(directory),
|
@@ -38,7 +40,7 @@ module Git
|
|
38
40
|
)
|
39
41
|
end
|
40
42
|
|
41
|
-
def workarea_status
|
43
|
+
def workarea_status(message, workarea, owner)
|
42
44
|
directory_status(
|
43
45
|
[
|
44
46
|
message,
|
@@ -49,37 +51,37 @@ module Git
|
|
49
51
|
)
|
50
52
|
end
|
51
53
|
|
52
|
-
def user_status
|
53
|
-
setting_status([
|
54
|
+
def user_status(user)
|
55
|
+
setting_status(['User', user], user && !user.empty?)
|
54
56
|
end
|
55
57
|
|
56
|
-
def organization_status
|
57
|
-
|
58
|
-
setting_status([
|
59
|
-
setting_status([
|
58
|
+
def organization_status(orgs)
|
59
|
+
orgs.each do |org|
|
60
|
+
setting_status(['Organization', org], org && !org.empty?, true)
|
61
|
+
setting_status(['Organization', 'member?'], Git::Hub.orgs.include?(org), !Git::Hub.connected?)
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
|
-
def token_status
|
64
|
-
setting_status([
|
65
|
-
setting_status([
|
66
|
-
setting_status([
|
65
|
+
def token_status(token)
|
66
|
+
setting_status(['Token', symbolize(token), describe(token)], !token.nil? && !token.empty?)
|
67
|
+
setting_status(['Token', 'valid?'], !token.nil? && !token.empty? && Git::Hub.login, !Git::Hub.connected?)
|
68
|
+
setting_status(['Token', "owned by #{Git::Multi::USER}?"], Git::Hub.login == Git::Multi::USER, !Git::Hub.connected?)
|
67
69
|
end
|
68
70
|
|
69
|
-
def home_status
|
70
|
-
directory_status([
|
71
|
+
def home_status(home)
|
72
|
+
directory_status(['Home', home], home)
|
71
73
|
end
|
72
74
|
|
73
|
-
def main_workarea_status
|
74
|
-
directory_status([
|
75
|
+
def main_workarea_status(workarea)
|
76
|
+
directory_status(['Workarea (main)', abbreviate(workarea, :home)], workarea)
|
75
77
|
end
|
76
78
|
|
77
|
-
def user_workarea_status
|
79
|
+
def user_workarea_status(user)
|
78
80
|
workarea_status("Workarea (user: #{user})", Git::Multi::WORKAREA, user)
|
79
81
|
end
|
80
82
|
|
81
|
-
def organization_workarea_status
|
82
|
-
|
83
|
+
def organization_workarea_status(orgs)
|
84
|
+
orgs.each do |org|
|
83
85
|
workarea_status("Workarea (org: #{org})", Git::Multi::WORKAREA, org)
|
84
86
|
end
|
85
87
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Git
|
2
|
+
module Multi
|
3
|
+
|
4
|
+
module Settings
|
5
|
+
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def describe(token)
|
9
|
+
if token.nil?
|
10
|
+
'(nil)'
|
11
|
+
elsif token.empty?
|
12
|
+
'(empty)'
|
13
|
+
else
|
14
|
+
"#{'*' * 36}#{token[36..-1]}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def symbolize(token)
|
19
|
+
case token
|
20
|
+
when Git::Multi.env_var('OCTOKIT_ACCESS_TOKEN')
|
21
|
+
then '${OCTOKIT_ACCESS_TOKEN}'
|
22
|
+
when Git::Multi.git_option('github.token')
|
23
|
+
then 'github.token'
|
24
|
+
else '(unset)'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def abbreviate(directory, root_dir = nil)
|
29
|
+
case root_dir
|
30
|
+
when :home
|
31
|
+
then directory.gsub(Git::Multi::HOME, '${HOME}')
|
32
|
+
when :workarea
|
33
|
+
then directory.gsub(Git::Multi::WORKAREA, '${WORKAREA}')
|
34
|
+
else abbreviate(abbreviate(directory, :workarea), :home)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
module_function
|
41
|
+
|
42
|
+
def git_option(name, default = nil)
|
43
|
+
value = `git config #{name}`.chomp.freeze
|
44
|
+
value.empty? && default ? default : value
|
45
|
+
end
|
46
|
+
|
47
|
+
def env_var(name, default = nil)
|
48
|
+
value = ENV[name].freeze
|
49
|
+
(value.nil? || value.empty?) && default ? default : value
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/git/multi/version.rb
CHANGED
@@ -1,37 +1,20 @@
|
|
1
1
|
require 'octokit'
|
2
2
|
require 'sawyer'
|
3
|
-
require '
|
3
|
+
require 'faraday'
|
4
|
+
require 'addressable'
|
4
5
|
|
5
6
|
module Git
|
6
7
|
module Multi
|
7
|
-
NAME = 'git-multi'
|
8
|
-
VERSION = '1.0.
|
8
|
+
NAME = 'git-multi'.freeze
|
9
|
+
VERSION = '1.0.6'.freeze
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
VERSION,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Sawyer::VERSION,
|
17
|
-
'psych',
|
18
|
-
Psych::VERSION,
|
19
|
-
]
|
11
|
+
DEPENDENCY_VERSIONS = [
|
12
|
+
"octokit.rb v#{Octokit::VERSION}",
|
13
|
+
"sawyer v#{Sawyer::VERSION}",
|
14
|
+
"faraday v#{Faraday::VERSION}",
|
15
|
+
"addressable v#{Addressable::VERSION::STRING}",
|
16
|
+
].join(', ').freeze
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
The required settings for \033[1mgit multi\33[0m are as follows:
|
24
|
-
|
25
|
-
\tgit config --global --add \033[1mgithub.user\033[0m <your_github_username>
|
26
|
-
\tgit config --global --add \033[1mgithub.organizations\033[0m <your_github_orgs>
|
27
|
-
\tgit config --global --add \033[1mgithub.token\033[0m <your_github_oauth_token>
|
28
|
-
|
29
|
-
Unless your top-level workarea is `${HOME}/Workarea` you should also set:
|
30
|
-
|
31
|
-
\tgit config --global --add \033[1mgit.multi.workarea\033[0m <your_root_workarea>
|
32
|
-
|
33
|
-
Thanks for using \033[1mgit multi\033[0m ... the ultimate multi-repo utility for git!
|
34
|
-
|
35
|
-
EOPIM
|
18
|
+
LONG_VERSION = "#{NAME} v#{VERSION} (#{DEPENDENCY_VERSIONS})".freeze
|
36
19
|
end
|
37
20
|
end
|
data/lib/git/multi.rb
CHANGED
@@ -8,14 +8,15 @@ require 'octokit'
|
|
8
8
|
require 'sawyer'
|
9
9
|
|
10
10
|
require 'ext/dir'
|
11
|
-
require 'ext/utils'
|
12
11
|
require 'ext/string'
|
13
12
|
require 'ext/notify'
|
13
|
+
require 'ext/kernel'
|
14
14
|
require 'ext/commify'
|
15
15
|
require 'ext/sawyer/resource'
|
16
16
|
|
17
17
|
require 'git/hub'
|
18
18
|
|
19
|
+
require 'git/multi/utils'
|
19
20
|
require 'git/multi/version'
|
20
21
|
require 'git/multi/settings'
|
21
22
|
require 'git/multi/commands'
|
@@ -86,18 +87,15 @@ module Git
|
|
86
87
|
|
87
88
|
module Nike
|
88
89
|
|
89
|
-
def just_do_it
|
90
|
-
working_dir = case options[:
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
def just_do_it(interactive, pipeline, options = {})
|
91
|
+
working_dir = case (options[:in] || '').to_sym
|
92
|
+
when :parent_dir then parent_dir
|
93
|
+
when :local_path then local_path
|
94
|
+
else Dir.pwd
|
95
|
+
end
|
95
96
|
Dir.chdir(working_dir) do
|
96
|
-
if
|
97
|
-
puts "
|
98
|
-
self.full_name.invert,
|
99
|
-
self.fractional_index
|
100
|
-
]
|
97
|
+
if interactive?
|
98
|
+
puts "#{full_name.invert} (#{fractional_index})"
|
101
99
|
interactive.call(self)
|
102
100
|
else
|
103
101
|
pipeline.call(self)
|
@@ -109,6 +107,7 @@ module Git
|
|
109
107
|
|
110
108
|
def repositories
|
111
109
|
if File.size?(REPOSITORIES)
|
110
|
+
# rubocop:disable Security/MarshalLoad
|
112
111
|
@repositories ||= Marshal.load(File.read(REPOSITORIES)).tap do |projects|
|
113
112
|
notify "Finished loading #{REPOSITORIES}"
|
114
113
|
projects.each_with_index do |project, index|
|
@@ -119,15 +118,17 @@ module Git
|
|
119
118
|
project.local_path = Pathname.new(File.join(WORKAREA, project.full_name))
|
120
119
|
project.fractional_index = "#{index + 1}/#{projects.count}"
|
121
120
|
# fix 'project' => https://github.com/octokit/octokit.rb/issues/727
|
122
|
-
project.compliant_ssh_url = 'ssh
|
121
|
+
project.compliant_ssh_url = 'ssh://' + project.ssh_url.split(':', 2).join('/')
|
123
122
|
# remove optional '.git' suffix from 'git@github.com:pvdb/git-multi.git'
|
124
123
|
project.abbreviated_ssh_url = project.ssh_url.chomp('.git')
|
125
124
|
# extend 'project' with 'just do it' capabilities
|
126
125
|
project.extend Nike
|
127
126
|
end
|
128
127
|
end
|
128
|
+
# rubocop:enable Security/MarshalLoad
|
129
129
|
else
|
130
|
-
refresh_repositories
|
130
|
+
refresh_repositories
|
131
|
+
repositories # retry
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
data/man/git-multi.1
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
.\" Title: git-multi
|
3
3
|
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
|
4
4
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
5
|
-
.\" Date: 09/
|
5
|
+
.\" Date: 09/23/2018
|
6
6
|
.\" Manual: Git Manual
|
7
7
|
.\" Source: Git 2.19.0.216.g2d3b1c576.dirty
|
8
8
|
.\" Language: English
|
9
9
|
.\"
|
10
|
-
.TH "GIT\-MULTI" "1" "09/
|
10
|
+
.TH "GIT\-MULTI" "1" "09/23/2018" "Git 2\&.19\&.0\&.216\&.g2d3b1c" "Git Manual"
|
11
11
|
.\" -----------------------------------------------------------------
|
12
12
|
.\" * Define some portability stuff
|
13
13
|
.\" -----------------------------------------------------------------
|
@@ -31,7 +31,7 @@
|
|
31
31
|
git-multi \- execute the same git command in multiple repositories
|
32
32
|
.SH "VERSION"
|
33
33
|
.sp
|
34
|
-
This is \fBv1\&.0\&.
|
34
|
+
This is \fBv1\&.0\&.6\fR of \fIgit multi\fR \&... hooray!
|
35
35
|
.SH "SYNOPSIS"
|
36
36
|
.sp
|
37
37
|
There are some options for \fBgit multi\fR itself, in which case it is invoked as follows:
|
data/man/git-multi.html
CHANGED
@@ -748,7 +748,7 @@ git-multi(1) Manual Page
|
|
748
748
|
<div class="sect1">
|
749
749
|
<h2 id="_version">VERSION</h2>
|
750
750
|
<div class="sectionbody">
|
751
|
-
<div class="paragraph"><p>This is <code>v1.0.
|
751
|
+
<div class="paragraph"><p>This is <code>v1.0.6</code> of <em>git multi</em> … hooray!</p></div>
|
752
752
|
</div>
|
753
753
|
</div>
|
754
754
|
<div class="sect1">
|
@@ -1179,7 +1179,7 @@ the <code>jq</code> command-line utility:
|
|
1179
1179
|
<div id="footer">
|
1180
1180
|
<div id="footer-text">
|
1181
1181
|
Last updated
|
1182
|
-
2018-09-
|
1182
|
+
2018-09-23 14:13:02 BST
|
1183
1183
|
</div>
|
1184
1184
|
</div>
|
1185
1185
|
</body>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-multi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Vandenberk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -91,14 +91,16 @@ files:
|
|
91
91
|
- git-multi.gemspec
|
92
92
|
- lib/ext/commify.rb
|
93
93
|
- lib/ext/dir.rb
|
94
|
+
- lib/ext/kernel.rb
|
94
95
|
- lib/ext/notify.rb
|
95
96
|
- lib/ext/sawyer/resource.rb
|
96
97
|
- lib/ext/string.rb
|
97
|
-
- lib/ext/utils.rb
|
98
98
|
- lib/git/hub.rb
|
99
99
|
- lib/git/multi.rb
|
100
100
|
- lib/git/multi/commands.rb
|
101
|
+
- lib/git/multi/gemspec.rb
|
101
102
|
- lib/git/multi/settings.rb
|
103
|
+
- lib/git/multi/utils.rb
|
102
104
|
- lib/git/multi/version.rb
|
103
105
|
- man/git-multi.1
|
104
106
|
- man/git-multi.erb
|
data/lib/ext/utils.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
$INTERACTIVE = (STDOUT.tty? && STDERR.tty?)
|
2
|
-
|
3
|
-
def git_option name, default = nil
|
4
|
-
value = `git config #{name}`.chomp.freeze
|
5
|
-
value.empty? && default ? default : value
|
6
|
-
end
|
7
|
-
|
8
|
-
def env_var name, default = nil
|
9
|
-
value = ENV[name].freeze
|
10
|
-
(value.nil? || value.empty?) && default ? default : value
|
11
|
-
end
|
12
|
-
|
13
|
-
def describe token
|
14
|
-
token.nil? ? '(nil)' : token.empty? ? '(empty)' : "#{'*'*36}#{token[36..-1]}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def symbolize token
|
18
|
-
case token
|
19
|
-
when env_var('OCTOKIT_ACCESS_TOKEN') then '${OCTOKIT_ACCESS_TOKEN}'
|
20
|
-
when git_option('github.token') then 'github.token'
|
21
|
-
else '(unset)'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def abbreviate directory, root_dir = nil
|
26
|
-
case root_dir
|
27
|
-
when :home then directory.gsub(Git::Multi::HOME, '${HOME}')
|
28
|
-
when :workarea then directory.gsub(Git::Multi::WORKAREA, '${WORKAREA}')
|
29
|
-
else abbreviate(abbreviate(directory, :workarea), :home)
|
30
|
-
end
|
31
|
-
end
|