git-pulls 0.4.11 → 0.4.12
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 +6 -14
- data/lib/git-pulls.rb +94 -72
- metadata +39 -11
checksums.yaml
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
metadata.gz: !binary |-
|
|
9
|
-
NWI0NmNmYzJhMzI3ZTAxNzI3ZjBlN2U2ZDRmNzYxNjgzZGE5MGZjNjRlNTIy
|
|
10
|
-
MTgyMzYxNTNiOTAwOTFlNTBjZTI3ZWE0Mjg2YWM5YzIxMjQzZTZjYzBmNTZk
|
|
11
|
-
MmM1ODA4N2MxOTQxNDhhY2MzMWMxMTY4ZDJkYjZiNTRkZWY3OWU=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
ZjQxNmM4YjM2MmEwN2Y5OGYxNTNlZGFlMDgwZWU0MDg1NTZhOTRlOTQzZWRm
|
|
14
|
-
MWNkODI2NTA1ZWE5ODk1NzExOWY1ZDcwODQ2MTk3ZWExM2Y2OWI0ZTZjZGI4
|
|
15
|
-
MTRhMzJjNTBkN2E5NTdmNWM3NWE5ZTc3ZGIxMDUyZGY3ZmExMDM=
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f35d8b240687ef48fd376f27c17aa41c29c72b41
|
|
4
|
+
data.tar.gz: 3f53f4db3eed289af7aaebbf13a8c4ffd240bb2f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9d85547f20bd78a3cf3b2ed674296a9610cae1e0181f8e9be3ab88ff0da72821cd85b1651df1d8cd162e4659e7492e581280d773c094da7417e5c175ea55052c
|
|
7
|
+
data.tar.gz: 1149f22240e3e3df7954a18a4dc347dca2cd6112f314380206754e5d0d3b948c7e921c9ea01fee96fd87cb12fee8c9ff2b087d8fb08aceea2202e477dad3af66
|
data/lib/git-pulls.rb
CHANGED
|
@@ -3,11 +3,13 @@ require 'json'
|
|
|
3
3
|
require 'date'
|
|
4
4
|
require 'launchy'
|
|
5
5
|
require 'octokit'
|
|
6
|
+
require 'psych'
|
|
6
7
|
|
|
7
8
|
class GitPulls
|
|
8
9
|
|
|
10
|
+
GIT_REMOTE = ENV['GIT_REMOTE'] || 'origin'
|
|
9
11
|
GIT_PATH = lambda { return `git rev-parse --git-dir`.chomp }
|
|
10
|
-
PULLS_CACHE_FILE = "#{GIT_PATH.call}/pulls_cache.
|
|
12
|
+
PULLS_CACHE_FILE = "#{GIT_PATH.call}/pulls_cache.yml"
|
|
11
13
|
|
|
12
14
|
def initialize(args)
|
|
13
15
|
@command = args.shift
|
|
@@ -63,33 +65,39 @@ Usage: git pulls update
|
|
|
63
65
|
def merge
|
|
64
66
|
num = @args.shift
|
|
65
67
|
option = @args.shift
|
|
66
|
-
if
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if pull = pull_num(num)
|
|
69
|
+
head = pull[:head].to_hash
|
|
70
|
+
user = pull[:user].to_hash
|
|
71
|
+
|
|
72
|
+
if repo = head[:repo] && head[:repo].to_hash
|
|
73
|
+
owner = repo[:owner].to_hash
|
|
74
|
+
repo_name = repo[:name]
|
|
75
|
+
|
|
76
|
+
sha = head[:sha]
|
|
77
|
+
|
|
78
|
+
message = "Merge pull request ##{num} from #{owner[:login]}/#{repo_name}\n\n---\n\n"
|
|
79
|
+
message += pull[:body].gsub("'", '')
|
|
80
|
+
cmd = ''
|
|
81
|
+
if option == '--log'
|
|
82
|
+
message += "\n\n---\n\nMerge Log:\n"
|
|
83
|
+
puts cmd = "git merge --no-ff --log -m '#{message}' #{sha}"
|
|
84
|
+
else
|
|
85
|
+
puts cmd = "git merge --no-ff -m '#{message}' #{sha}"
|
|
86
|
+
end
|
|
87
|
+
exec(cmd)
|
|
88
|
+
|
|
70
89
|
else # they deleted the source repo
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
90
|
+
owner = head[:user].to_hash[:login]
|
|
91
|
+
patch_url = "#{pull[:_links].to_hash[:html].to_hash[:href]}.patch"
|
|
92
|
+
|
|
93
|
+
puts "Sorry, #{owner} deleted the source repository, git-pulls doesn't support this."
|
|
74
94
|
puts "You can manually patch your repo by running:"
|
|
75
95
|
puts
|
|
76
|
-
puts " curl #{
|
|
96
|
+
puts " curl #{patch_url} | git am"
|
|
77
97
|
puts
|
|
78
98
|
puts "Tell the contributor not to do this."
|
|
79
99
|
return false
|
|
80
100
|
end
|
|
81
|
-
s = p['head']['sha']
|
|
82
|
-
|
|
83
|
-
message = "Merge pull request ##{num} from #{o}/#{r}\n\n---\n\n"
|
|
84
|
-
message += p['body'].gsub("'", '')
|
|
85
|
-
cmd = ''
|
|
86
|
-
if option == '--log'
|
|
87
|
-
message += "\n\n---\n\nMerge Log:\n"
|
|
88
|
-
puts cmd = "git merge --no-ff --log -m '#{message}' #{s}"
|
|
89
|
-
else
|
|
90
|
-
puts cmd = "git merge --no-ff -m '#{message}' #{s}"
|
|
91
|
-
end
|
|
92
|
-
exec(cmd)
|
|
93
101
|
else
|
|
94
102
|
puts "No such number"
|
|
95
103
|
end
|
|
@@ -99,40 +107,47 @@ Usage: git pulls update
|
|
|
99
107
|
num = @args.shift
|
|
100
108
|
optiona = @args.shift
|
|
101
109
|
optionb = @args.shift
|
|
102
|
-
|
|
110
|
+
|
|
111
|
+
if pull = pull_num(num)
|
|
112
|
+
head = pull[:head].to_hash
|
|
113
|
+
repo = head[:repo].to_hash
|
|
114
|
+
user = pull[:user].to_hash
|
|
115
|
+
|
|
103
116
|
comments = []
|
|
104
117
|
if optiona == '--comments' || optionb == '--comments'
|
|
105
|
-
i_comments = Octokit.issue_comments("#{@user}/#{@repo}", num)
|
|
106
|
-
p_comments = Octokit.pull_request_comments("#{@user}/#{@repo}", num)
|
|
107
|
-
c_comments = Octokit.commit_comments(
|
|
108
|
-
comments = (i_comments | p_comments | c_comments).sort_by {|i| i[
|
|
118
|
+
i_comments = Octokit.issue_comments("#{@user}/#{@repo}", num).map(&:to_hash)
|
|
119
|
+
p_comments = Octokit.pull_request_comments("#{@user}/#{@repo}", num).map(&:to_hash)
|
|
120
|
+
c_comments = Octokit.commit_comments(repo[:full_name], head[:sha])
|
|
121
|
+
comments = (i_comments | p_comments | c_comments).sort_by {|i| i[:created_at]}
|
|
109
122
|
end
|
|
110
|
-
puts "Number : #{
|
|
111
|
-
puts "Label : #{
|
|
112
|
-
puts "Creator : #{
|
|
113
|
-
puts "Created : #{
|
|
123
|
+
puts "Number : #{pull[:number]}"
|
|
124
|
+
puts "Label : #{head[:label]}"
|
|
125
|
+
puts "Creator : #{user[:login]}"
|
|
126
|
+
puts "Created : #{pull[:created_at]}"
|
|
114
127
|
puts
|
|
115
|
-
puts "Title : #{
|
|
128
|
+
puts "Title : #{pull[:title]}"
|
|
116
129
|
puts
|
|
117
|
-
puts
|
|
130
|
+
puts pull[:body]
|
|
118
131
|
puts
|
|
119
132
|
puts '------------'
|
|
120
133
|
puts
|
|
121
|
-
comments.each do |
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
puts "
|
|
134
|
+
comments.each do |comment|
|
|
135
|
+
user = comment[:user]
|
|
136
|
+
|
|
137
|
+
puts "Comment : #{user[:login]}"
|
|
138
|
+
puts "Created : #{comment[:created_at]}"
|
|
139
|
+
puts "File : #{comment[:path]}:L#{comment[:line] || comment[:position] || comment[:original_position]}" unless comment[:path].nil?
|
|
125
140
|
puts
|
|
126
|
-
puts
|
|
141
|
+
puts comment[:body]
|
|
127
142
|
puts
|
|
128
143
|
puts '------------'
|
|
129
144
|
puts
|
|
130
145
|
end
|
|
131
146
|
if optiona == '--full' || optionb == '--full'
|
|
132
|
-
exec "git diff --color=always HEAD...#{
|
|
147
|
+
exec "git diff --color=always HEAD...#{head[:sha]}"
|
|
133
148
|
else
|
|
134
|
-
puts "cmd: git diff HEAD...#{
|
|
135
|
-
puts git("diff --stat --color=always HEAD...#{
|
|
149
|
+
puts "cmd: git diff HEAD...#{head[:sha]}"
|
|
150
|
+
puts git("diff --stat --color=always HEAD...#{head[:sha]}")
|
|
136
151
|
end
|
|
137
152
|
else
|
|
138
153
|
puts "No such number"
|
|
@@ -141,8 +156,8 @@ Usage: git pulls update
|
|
|
141
156
|
|
|
142
157
|
def browse
|
|
143
158
|
num = @args.shift
|
|
144
|
-
if
|
|
145
|
-
Launchy.open(
|
|
159
|
+
if pull = pull_num(num)
|
|
160
|
+
Launchy.open(pull[:_links].to_hash[:html].to_hash[:href])
|
|
146
161
|
else
|
|
147
162
|
puts "No such number"
|
|
148
163
|
end
|
|
@@ -162,21 +177,19 @@ Usage: git pulls update
|
|
|
162
177
|
pulls = state == 'open' ? get_open_pull_info : get_closed_pull_info
|
|
163
178
|
pulls.reverse! if option == '--reverse'
|
|
164
179
|
|
|
165
|
-
count = 0
|
|
166
180
|
pulls.each do |pull|
|
|
181
|
+
pull = pull.to_hash
|
|
182
|
+
head = pull[:head].to_hash
|
|
183
|
+
|
|
167
184
|
line = []
|
|
168
|
-
line << l(pull[
|
|
169
|
-
line << l(Date.parse(pull[
|
|
170
|
-
line << l(pull[
|
|
171
|
-
line << l(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if not_merged?(sha)
|
|
175
|
-
puts line.join ' '
|
|
176
|
-
count += 1
|
|
177
|
-
end
|
|
185
|
+
line << l(pull[:number], 4)
|
|
186
|
+
line << l(Date.parse(pull[:created_at].to_s).strftime("%m/%d"), 5)
|
|
187
|
+
line << l(pull[:title], 35)
|
|
188
|
+
line << l(head[:label], 50)
|
|
189
|
+
|
|
190
|
+
puts line.join ' '
|
|
178
191
|
end
|
|
179
|
-
if count == 0
|
|
192
|
+
if pulls.count == 0
|
|
180
193
|
puts ' -- no ' + state + ' pull requests --'
|
|
181
194
|
end
|
|
182
195
|
end
|
|
@@ -185,9 +198,11 @@ Usage: git pulls update
|
|
|
185
198
|
puts "Checking out all open pull requests for #{@user}/#{@repo}"
|
|
186
199
|
pulls = get_open_pull_info
|
|
187
200
|
pulls.each do |pull|
|
|
188
|
-
|
|
201
|
+
head = pull[:head].to_hash
|
|
202
|
+
branch_ref = head[:ref]
|
|
203
|
+
|
|
189
204
|
puts "> #{branch_ref} into pull-#{branch_ref}"
|
|
190
|
-
git("branch --track #{@args.join(' ')} pull-#{branch_ref}
|
|
205
|
+
git("branch --track #{@args.join(' ')} pull-#{branch_ref} #{GIT_REMOTE}/#{branch_ref}")
|
|
191
206
|
end
|
|
192
207
|
end
|
|
193
208
|
|
|
@@ -200,15 +215,22 @@ Usage: git pulls update
|
|
|
200
215
|
|
|
201
216
|
def fetch_stale_forks
|
|
202
217
|
puts "Checking for forks in need of fetching"
|
|
218
|
+
|
|
203
219
|
pulls = get_open_pull_info | get_closed_pull_info
|
|
204
220
|
repos = {}
|
|
205
221
|
pulls.each do |pull|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
head = pull[:head].to_hash
|
|
223
|
+
|
|
224
|
+
unless repo = head[:repo] && head[:repo].to_hash
|
|
225
|
+
next # Fork has been deleted
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
owner = repo[:owner].to_hash
|
|
229
|
+
repo_name = repo[:name]
|
|
230
|
+
sha = head[:sha]
|
|
231
|
+
|
|
232
|
+
unless has_sha?(sha)
|
|
233
|
+
repo = "#{owner[:login]}/#{repo_name}"
|
|
212
234
|
repos[repo] = true
|
|
213
235
|
end
|
|
214
236
|
end
|
|
@@ -223,7 +245,7 @@ Usage: git pulls update
|
|
|
223
245
|
end
|
|
224
246
|
end
|
|
225
247
|
|
|
226
|
-
def has_sha(sha)
|
|
248
|
+
def has_sha?(sha)
|
|
227
249
|
git("show #{sha} 2>&1")
|
|
228
250
|
$?.exitstatus == 0
|
|
229
251
|
end
|
|
@@ -254,7 +276,7 @@ Usage: git pulls update
|
|
|
254
276
|
|
|
255
277
|
config.login = github_login if github_login and not github_login.empty?
|
|
256
278
|
config.web_endpoint = github_endpoint
|
|
257
|
-
config.
|
|
279
|
+
config.access_token = github_token if github_token and not github_token.empty?
|
|
258
280
|
config.proxy = github_proxy if github_proxy and not github_proxy.empty?
|
|
259
281
|
config.api_endpoint = github_api_endpoint if (github_api_endpoint and \
|
|
260
282
|
not github_api_endpoint.empty?)
|
|
@@ -301,32 +323,32 @@ Usage: git pulls update
|
|
|
301
323
|
end
|
|
302
324
|
|
|
303
325
|
def get_closed_pull_info
|
|
304
|
-
get_data(PULLS_CACHE_FILE)['closed']
|
|
326
|
+
get_data(PULLS_CACHE_FILE)['closed'].map(&:to_hash)
|
|
305
327
|
end
|
|
306
328
|
|
|
307
329
|
def get_open_pull_info
|
|
308
|
-
get_data(PULLS_CACHE_FILE)['open']
|
|
330
|
+
get_data(PULLS_CACHE_FILE)['open'].map(&:to_hash)
|
|
309
331
|
end
|
|
310
332
|
|
|
311
333
|
def get_data(file)
|
|
312
|
-
|
|
334
|
+
::Psych.load_file(file)
|
|
313
335
|
end
|
|
314
336
|
|
|
315
337
|
def cache_pull_info
|
|
316
|
-
response_o = Octokit.pull_requests("#{@user}/#{@repo}")
|
|
338
|
+
response_o = Octokit.pull_requests("#{@user}/#{@repo}", 'open')
|
|
317
339
|
response_c = Octokit.pull_requests("#{@user}/#{@repo}", 'closed')
|
|
318
340
|
save_data({'open' => response_o, 'closed' => response_c}, PULLS_CACHE_FILE)
|
|
319
341
|
end
|
|
320
342
|
|
|
321
343
|
def save_data(data, file)
|
|
322
344
|
File.open(file, "w+") do |f|
|
|
323
|
-
f.puts data
|
|
345
|
+
f.puts Psych.dump(data)
|
|
324
346
|
end
|
|
325
347
|
end
|
|
326
348
|
|
|
327
349
|
def pull_num(num)
|
|
328
|
-
pull = get_open_pull_info.select { |p| p[
|
|
329
|
-
pull ||= get_closed_pull_info.select { |p| p[
|
|
350
|
+
pull = get_open_pull_info.select { |p| p[:number].to_s == num.to_s }.first
|
|
351
|
+
pull ||= get_closed_pull_info.select { |p| p[:number].to_s == num.to_s }.first
|
|
330
352
|
pull
|
|
331
353
|
end
|
|
332
354
|
|
|
@@ -370,7 +392,7 @@ Usage: git pulls update
|
|
|
370
392
|
k, v = line.split('=')
|
|
371
393
|
c[k] = v
|
|
372
394
|
end
|
|
373
|
-
u = c[
|
|
395
|
+
u = c["remote.#{GIT_REMOTE}.url"]
|
|
374
396
|
|
|
375
397
|
user, proj = github_user_and_proj(u)
|
|
376
398
|
if !(user and proj)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: git-pulls
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adrien Giboire
|
|
@@ -9,48 +9,76 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: json
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- -
|
|
18
|
+
- - '>='
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
20
|
version: '0'
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
|
-
- -
|
|
25
|
+
- - '>='
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '0'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: launchy
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- -
|
|
32
|
+
- - '>='
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
34
|
version: '0'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
|
-
- -
|
|
39
|
+
- - '>='
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: '0'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: octokit
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
|
-
- -
|
|
46
|
+
- - ~>
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version:
|
|
48
|
+
version: 2.6.1
|
|
49
49
|
type: :runtime
|
|
50
50
|
prerelease: false
|
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
|
53
|
-
- -
|
|
53
|
+
- - ~>
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 2.6.1
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: minitest
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - '>='
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: rake
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - '>='
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - '>='
|
|
54
82
|
- !ruby/object:Gem::Version
|
|
55
83
|
version: '0'
|
|
56
84
|
description: git-pulls facilitates github pull requests.
|
|
@@ -72,12 +100,12 @@ require_paths:
|
|
|
72
100
|
- lib
|
|
73
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
102
|
requirements:
|
|
75
|
-
- -
|
|
103
|
+
- - '>='
|
|
76
104
|
- !ruby/object:Gem::Version
|
|
77
105
|
version: '0'
|
|
78
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
107
|
requirements:
|
|
80
|
-
- -
|
|
108
|
+
- - '>='
|
|
81
109
|
- !ruby/object:Gem::Version
|
|
82
110
|
version: '0'
|
|
83
111
|
requirements: []
|