git-multi 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: be442e1218245c5f96d38cd0c046774417fd336af6c644a5322d873763f341b4
4
- data.tar.gz: 8bcdb2fd482ffad4497989c12e2dc273977f24ba9fe1f0809713f83a15a3e545
3
+ metadata.gz: 4544f95968635dcc0d38c32adb78b097bf36ac427d57cca5e61f0d7e686dabc1
4
+ data.tar.gz: 8b2a42a673f0c048911db0d3458d215bf11fab6c67b2e5da527bae389a6217fe
5
5
  SHA512:
6
- metadata.gz: 394a92a4649a3468c6fe36ea2d2d4128b3297c724196df0f5d3322373ba53c7a159e860dedcf4c9b9ef6947ac9d843176788ad2c007ed8dad021a90c1805e737
7
- data.tar.gz: 27d6e8aced92a3ea3a68d4702fa8a8f2ed5137f8e910bcd5a9f416a985a43b48024484ee453c92326939efccecda524d7f01cb5277f81c213998f016f906a18f
6
+ metadata.gz: 329f010f1be5c413e40409c1f640b638ee2830e44241d65bcd5ba9cdc3527a51ca7fc2ac128b4b2866f8f13f91a021012ab46d9f75bee0d2c172f2898120252e
7
+ data.tar.gz: 0117a4c5691767fc6ca068a34adc5242b270894f54cd189574a9db9b45975ef68b7e50cc6ceabd6986eaa92bdc5fb923527236694296c5c47ef9ebf0c27dcb04
data/doc/git-multi.txt ADDED
@@ -0,0 +1,232 @@
1
+ git-multi(1)
2
+ ============
3
+
4
+ NAME
5
+ ----
6
+
7
+ git-multi - execute the same git command in multiple repositories
8
+
9
+ SYNOPSIS
10
+ --------
11
+
12
+ There are some options for `git multi` itself, in which case it
13
+ is invoked as follows:
14
+
15
+ [verse]
16
+ 'git multi' <dash_dash_option> [<option_arguments>]
17
+
18
+ To execute the same git command in multiple repositories, the
19
+ invocation is as follows:
20
+
21
+ [verse]
22
+ 'git multi' <git_command> [<git_command_arguments>]
23
+
24
+ DESCRIPTION
25
+ -----------
26
+
27
+ Convenient way to execute the same git command in a set of related repos,
28
+ currently the repositories of a GitHub user, incl. the organizations they
29
+ are a member of; the repo list is determined via a GitHub API v3 call, and
30
+ cached locally '(in binary format)' for performance and offline usage.
31
+
32
+ OPTIONS
33
+ -------
34
+
35
+ --help::
36
+ you're looking at it
37
+
38
+ --check::
39
+ checks all the required settings and configurations
40
+
41
+ --version::
42
+ print out this script's version number
43
+
44
+ --refresh::
45
+ refresh the list of user & organization repos
46
+
47
+ --json::
48
+ output repository details to JSON
49
+
50
+ --count::
51
+ print out the count of repos (per type)
52
+
53
+ --list::
54
+ print out the names of all repos
55
+
56
+ --archived::
57
+ print out the names of all repos
58
+
59
+ --forked::
60
+ print out the names of all repos
61
+
62
+ --private::
63
+ print out the names of all repos
64
+
65
+ --paths::
66
+ print out the full path for each repos
67
+
68
+ --spurious::
69
+ list cloned repos whose remote doesn't match a github.com origin
70
+
71
+ --missing::
72
+ print out names of repos that haven't been cloned
73
+
74
+ --stale::
75
+ list repos that have been deleted on github.com
76
+
77
+ --excess::
78
+ list repos that don't exist on github.com
79
+
80
+ --clone::
81
+ clones missing repositories into `${HOME}/Workarea` (by default)
82
+
83
+ --query (args)::
84
+ query GitHub repo metadata for each repository
85
+
86
+ --find <ruby>::
87
+ print out the repos for which the Ruby code evaluates to true
88
+
89
+ --eval <ruby>::
90
+ execute the given Ruby code in the context of each repo
91
+
92
+ --raw <cmd>::
93
+ execute the given shell command inside each git repository
94
+
95
+ EXAMPLES
96
+ --------
97
+
98
+ count the number of repos
99
+
100
+ git multi --list | wc -l
101
+
102
+ disk usage of each locally cloned repo
103
+
104
+ git multi --paths | xargs -n 1 du -hs
105
+
106
+ disk usage using the `--raw` option
107
+
108
+ git multi --raw 'du -hs .'
109
+
110
+ group and count the repos by GitHub-determined language
111
+
112
+ git multi --query language | cut -f 2 -d : | sort | uniq -c | sort -n -r
113
+
114
+ find out the most-used Ruby versions
115
+
116
+ git multi --raw '[ -f .ruby-version ] && cat .ruby-version' | cut -f 2 -d : | sort | uniq -c | sort -n -r
117
+
118
+ find GitHub repos without a description
119
+
120
+ git multi --query description | egrep ': *$'
121
+
122
+ fetch remote branches for all repos
123
+
124
+ git multi fetch -p
125
+
126
+ print out the local branch for each repo
127
+
128
+ git multi rev-parse --abbrev-ref=strict HEAD
129
+
130
+ find all repos for which the 'origin' remote isn't github.com
131
+
132
+ git multi config --get remote.origin.url | fgrep -v git@github.com:
133
+
134
+ a kind of "repository creation" report: count the number of repos created in each quarter
135
+
136
+ git multi --eval "class ::Time; def quarter() (month.to_f / 3.0).ceil; end; end; puts format('%%d-Q%%d', created_at.year, created_at.quarter)" | sort | uniq -c
137
+
138
+ for each repo, list all remote branches, sorted by the "age" of the last commit on each branch
139
+
140
+ git multi for-each-ref --sort="-authordate" --format="%%(refname)%%09%%(authordate:relative)%%09%%(authorname)" refs/remotes/origin
141
+
142
+ same as above, but columnize the generated output (NOTE: replace '^I' with CTRL-V/CTRL-I in your terminal)
143
+
144
+ git multi for-each-ref --sort="-authordate" --format="%%(refname)%%09%%(authordate:relative)%%09%%(authorname)" refs/remotes/origin | column -t -s "^I"
145
+
146
+ same as above, but refresh the list of remote branches first
147
+
148
+ git multi fetch -p ; git multi for-each-ref --sort="-authordate" --format="%%(refname)%%09%%(authordate:relative)%%09%%(authorname)" refs/remotes/origin
149
+
150
+ find all Rails projects
151
+
152
+ git multi --raw '[ -f Gemfile ] && fgrep -q -l rails Gemfile && echo uses Rails' | cat
153
+
154
+ find all Mongoid dependencies
155
+
156
+ git multi --raw '[ -f Gemfile.lock ] && egrep -i "^ mongoid (.*)" Gemfile.lock' | column -s: -t
157
+
158
+ find all projects that have been pushed to in the last week
159
+
160
+ git multi --find '((Time.now - pushed_at) / 60 / 60 / 24) <= 7'
161
+
162
+ print out the number of days since the last push to each repository
163
+
164
+ git multi --eval 'puts "%%d days" %% ((Time.now - pushed_at) / 60 / 60 / 24)'
165
+
166
+ find all projects that have seen activity this calendar year
167
+
168
+ git multi --find 'pushed_at >= Date.civil(Date.today.year, 1, 1).to_time'
169
+
170
+ print out all webhooks
171
+
172
+ git multi --eval '(hooks = client.hooks(project.full_name)).any? && begin print project.full_name ; print "\t" ; puts hooks.map { |hook| ["", hook.name, hook.config.url].join("\t") } ; end'
173
+
174
+ print out all deploy keys
175
+
176
+ git multi --eval '(keys = client.list_deploy_keys(project.full_name)).any? && begin print project.full_name ; print "\t" ; puts keys.map(&:title).sort.join("\t") ; end'
177
+
178
+ find all organization repositories that depend on a given org repo, e.g. 'business_rules'
179
+
180
+ git multi --graph | fgrep business_rules
181
+
182
+ generate a dependency graph of all organization repositories using yuml.me
183
+
184
+ DEPENDENCIES=$( git multi --graph | ruby -n -e 'parent, children = $_.split(": ") ; puts children.split(" ").map { |child| "[#{parent}]->[#{child}]" }' | tr '\n' ',' ) ; open "http://yuml.me/diagram/scruffy/class/${DEPENDENCIES}"
185
+
186
+ generate a dependency graph of all organization repositories using Graphviz
187
+
188
+ git multi --graph | ruby -n -e 'parent, children = $_.split(": ") ; puts children.split(" ").map { |child| "\"#{parent}\"->\"#{child}\";" }' | awk 'BEGIN { print "digraph {\nrankdir=\"LR\";\n" } ; { print ; } END { print "}\n" } ; ' | dot -Tpng > /tmp/ghor.png ; open -a Preview /tmp/ghor.png
189
+
190
+ QUERY ARGUMENTS
191
+ ---------------
192
+
193
+ The following is a list of valid arguments for the `git multi --query` option:
194
+
195
+ %{query_args}
196
+
197
+ JQ INTEGRATION
198
+ --------------
199
+
200
+ `jq` is like `sed` for JSON data... all of the above query arguments can be
201
+ used in conjunction with `jq` to query, filter, map and transform the GitHub
202
+ repository attributes stored in the local, binary repository cache; here
203
+ are some examples:
204
+
205
+ # print out each repository's name and its description
206
+ git multi --json | jq '.[] | .name + ": " + .description'
207
+
208
+ # print out the name of all "forked" repositories
209
+ git multi --json | jq '.[] | select(.fork == true) | .full_name'
210
+
211
+ FILES
212
+ -----
213
+
214
+ `${HOME}/Workarea`::
215
+ root directory where repos will been cloned
216
+
217
+ `${HOME}/.git/multi/repositories.byte`::
218
+ local, binary cache of GitHub repository metadata
219
+
220
+ REFERENCES
221
+ ----------
222
+
223
+ * homepage for `git-multi`:
224
+ https://github.com/pvdb/git-multi
225
+
226
+ * the GitHub API:
227
+ https://developer.github.com/v3/
228
+
229
+ * the `jq` command-line utility:
230
+ http://stedolan.github.io/jq/
231
+
232
+ git-multi v%{vv} 1 October 2018 GIT-MULTI(1)
data/lib/git/multi.rb CHANGED
@@ -37,7 +37,7 @@ module Git
37
37
  USER = git_option('github.user')
38
38
  ORGANIZATIONS = git_option('github.organizations').split(/\s*,\s*/)
39
39
 
40
- MAN_PAGE = File.expand_path('../../doc/git-multi.man', __dir__)
40
+ MAN_PAGE = File.expand_path('../../doc/git-multi.txt', __dir__)
41
41
 
42
42
  module_function
43
43
 
@@ -27,7 +27,7 @@ module Git
27
27
  |foo, bar, qux| '%-20s %-20s %-20s' % [foo, bar, qux]
28
28
  }
29
29
  puts File.read(Git::Multi::MAN_PAGE) % {
30
- :version => Git::Multi::VERSION,
30
+ :vv => Git::Multi::VERSION,
31
31
  :query_args => query_args.join("\n "),
32
32
  }
33
33
  end
@@ -5,7 +5,7 @@ require 'psych'
5
5
  module Git
6
6
  module Multi
7
7
  NAME = 'git-multi'
8
- VERSION = '1.0.2'
8
+ VERSION = '1.0.3'
9
9
 
10
10
  LONG_VERSION = "%s v%s (%s v%s, %s v%s, %s v%s)" % [
11
11
  NAME,
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.2
4
+ version: 1.0.3
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-18 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -87,7 +87,7 @@ files:
87
87
  - bin/setup
88
88
  - contrib/git-dash/git-dash.erb
89
89
  - contrib/git-dash/git-dash.rb
90
- - doc/git-multi.man
90
+ - doc/git-multi.txt
91
91
  - exe/git-multi
92
92
  - git-multi.gemspec
93
93
  - lib/ext/commify.rb
data/doc/git-multi.man DELETED
@@ -1,143 +0,0 @@
1
- GIT-META(1) Git Extensions GIT-META(1)
2
-
3
- NAME
4
- git-multi -- execute the same git command in multiple repositories
5
-
6
-
7
- SYNOPSIS
8
- git multi <some_git_command_with_relevant_arguments>
9
-
10
- DESCRIPTION
11
- Convenient way to execute the same git command in a set of related repos,
12
- currently the list of an organization's repositories on Github.
13
-
14
- Said list is determined via a Github API v3 call, and cached locally for
15
- performance.
16
-
17
- OPTIONS
18
-
19
- git multi --help # you're looking at it
20
- git multi --check # checks all the required settings and configurations
21
- git multi --version # print out this script's version number
22
- git multi --refresh # refresh the list of organization repos
23
- git multi --json # output repository details to JSON
24
- git multi --count # print out the count of organization repos (per type)
25
- git multi --list # print out the names of all organization repos
26
- git multi --archived # print out the names of all organization repos
27
- git multi --forked # print out the names of all organization repos
28
- git multi --private # print out the names of all organization repos
29
- git multi --paths # print out the full path for each organization repos
30
- git multi --spurious # list cloned repos whose remote doesn't match a github.com origin
31
- git multi --missing # print out names of repos that haven't been cloned
32
- git multi --stale # list repos that have been deleted on github.com
33
- git multi --excess # list repos that don't exist on github.com
34
- git multi --clone # clones missing repositories into "${HOME}/Workarea" (by default)
35
- git multi --query (args) # query Github repo multidata for each repository
36
- git multi --find <ruby> # print out the repos for which the Ruby code evaluates to true
37
- git multi --eval <ruby> # execute the given Ruby code in the context of each repo
38
- get multi --raw <cmd> # execute the given shell command inside each git repository
39
-
40
- EXAMPLES
41
-
42
- # count the number of organization repos
43
- git multi --list | wc -l
44
-
45
- # disk usage of each locally cloned organization repo
46
- git multi --paths | xargs -n 1 du -hs
47
-
48
- # ... or by using the `--raw` option
49
- git multi --raw 'du -hs .'
50
-
51
- # group and count the repos by Github-determined language
52
- git multi --query language | cut -f 2 -d : | sort | uniq -c | sort -n -r
53
-
54
- # find out the most-used Ruby versions
55
- git multi --raw '[ -f .ruby-version ] && cat .ruby-version' | cut -f 2 -d : | sort | uniq -c | sort -n -r
56
-
57
- # find Github repos without a description
58
- git multi --query description | egrep ': *$'
59
-
60
- # fetch remote branches for all organization repos
61
- git multi fetch -p
62
-
63
- # print out the local branch for each repo
64
- git multi rev-parse --abbrev-ref=strict HEAD
65
-
66
- # find all repos for which the 'origin' remote isn't github.com
67
- git multi config --get remote.origin.url | fgrep -v git@github.com:
68
-
69
- # a kind of "repository creation" report: count the number of repos created in each quarter
70
- git multi --eval "class ::Time; def quarter() (month.to_f / 3.0).ceil; end; end; puts format('%%d-Q%%d', created_at.year, created_at.quarter)" | sort | uniq -c
71
-
72
- # for each repo, list all remote branches, sorted by the "age" of the last commit on each branch
73
- git multi for-each-ref --sort="-authordate" --format="%%(refname)%%09%%(authordate:relative)%%09%%(authorname)" refs/remotes/origin
74
-
75
- # same as above, but columnize the generated output (NOTE: replace '^I' with CTRL-V/CTRL-I in your terminal)
76
- git multi for-each-ref --sort="-authordate" --format="%%(refname)%%09%%(authordate:relative)%%09%%(authorname)" refs/remotes/origin | column -t -s "^I"
77
-
78
- # same as above, but refresh the list of remote branches first
79
- git multi fetch -p ; git multi for-each-ref --sort="-authordate" --format="%%(refname)%%09%%(authordate:relative)%%09%%(authorname)" refs/remotes/origin
80
-
81
- # find all organization repositories that depend on a given org repo, e.g. 'business_rules'
82
- git multi --graph | fgrep business_rules
83
-
84
- # find all Rails projects
85
- git multi --raw '[ -f Gemfile ] && fgrep -q -l rails Gemfile && echo uses Rails' | cat
86
-
87
- # find all Mongoid dependencies
88
- git multi --raw '[ -f Gemfile.lock ] && egrep -i "^ mongoid (.*)" Gemfile.lock' | column -s: -t
89
-
90
- # find all projects that have been pushed to in the last week
91
- git multi --find '((Time.now - pushed_at) / 60 / 60 / 24) <= 7'
92
-
93
- # print out the number of days since the last push to each repository
94
- git multi --eval 'puts "%%d days" %% ((Time.now - pushed_at) / 60 / 60 / 24)'
95
-
96
- # find all projects that have seen activity this calendar year
97
- git multi --find 'pushed_at >= Date.civil(Date.today.year, 1, 1).to_time'
98
-
99
- # print out all webhooks
100
- git multi --eval '(hooks = client.hooks(project.full_name)).any? && begin print project.full_name ; print "\t" ; puts hooks.map { |hook| ["", hook.name, hook.config.url].join("\t") } ; end'
101
-
102
- # print out all deploy keys
103
- git multi --eval '(keys = client.list_deploy_keys(project.full_name)).any? && begin print project.full_name ; print "\t" ; puts keys.map(&:title).sort.join("\t") ; end'
104
-
105
- # generate a dependency graph of all organization repositories using yuml.me
106
- DEPENDENCIES=$( git multi --graph | ruby -n -e 'parent, children = $_.split(": ") ; puts children.split(" ").map { |child| "[#{parent}]->[#{child}]" }' | tr '\n' ',' ) ; open "http://yuml.me/diagram/scruffy/class/${DEPENDENCIES}"
107
-
108
- # generate a dependency graph of all organization repositories using Graphviz
109
- git multi --graph | ruby -n -e 'parent, children = $_.split(": ") ; puts children.split(" ").map { |child| "\"#{parent}\"->\"#{child}\";" }' | awk 'BEGIN { print "digraph {\nrankdir=\"LR\";\n" } ; { print ; } END { print "}\n" } ; ' | dot -Tpng > /tmp/ghor.png ; open -a Preview /tmp/ghor.png
110
-
111
- QUERY ARGUMENTS
112
-
113
- The following is a list of valid arguments for the 'git multi --query' option
114
-
115
- %{query_args}
116
-
117
- USE `jq` TO QUERY THE `git multi` CACHE
118
-
119
- `jq` is like `sed` for JSON data... all of the above query arguments can be
120
- used in conjunction with `jq` to query, filter, map and transform the github
121
- repository attributes stored in `${HOME}/.gitmulti.byte`
122
-
123
- EXAMPLES
124
-
125
- # print out each repository's name and its description
126
- git multi --json | jq '.[] | .name + ": " + .description'
127
-
128
- # print out the name of all "forked" repositories
129
- git multi --json | jq '.[] | select(.fork == true) | .full_name'
130
-
131
- FILES
132
-
133
- ${HOME}/Workarea # root directory where organization repos have been cloned
134
-
135
- REFERENCES
136
-
137
- # the Github API call used to refresh the list of organization repos
138
- http://developer.github.com/v3/orgs/teams/#list-team-repos
139
-
140
- # the `jq` command-line utility
141
- http://stedolan.github.io/jq/
142
-
143
- git-multi %{version} 1 March 2015 GIT-META(1)