git-pr-release 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/git-pr-release +56 -39
- data/git-pr-release.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bc50424a98694a90f526c8685e4ea743a46b9d6
|
4
|
+
data.tar.gz: 934bf70ff7c35846b4d525023e20593d9dbd2385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8110e2381e583f4cdf913d02b85a6b2978cf0344b0b6a5791980e26bcd26bec6bc1f3398d199d93b4dfba1cbaaa312de0985ca04d1cbc16f60aa79a5cfeb8f5
|
7
|
+
data.tar.gz: 7243843af08eba2a5bacf9f72bdc0b1ffc6a5f6eb598ab0d2b0a7af711b997b95d6e7179adc61ae961029d530365a8888cca0b7018d7bfd7b584b5ad4b8aebce
|
data/README.md
CHANGED
data/bin/git-pr-release
CHANGED
@@ -18,7 +18,26 @@ class PullRequest
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_checklist_item
|
21
|
-
"- [ ] ##{pr.number} #{pr.title}" +
|
21
|
+
"- [ ] ##{pr.number} #{pr.title}" +
|
22
|
+
(pr.assignee ? " @#{pr.assignee.login}" : pr.user ? " @#{pr.user.login}" : "")
|
23
|
+
end
|
24
|
+
|
25
|
+
def html_link
|
26
|
+
pr.rels[:html].href
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class DummyPullRequest
|
31
|
+
def initialize
|
32
|
+
# nop
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_checklist_item
|
36
|
+
"- [ ] #??? THIS IS DUMMY PULL REQUEST"
|
37
|
+
end
|
38
|
+
|
39
|
+
def html_link
|
40
|
+
'http://github.com/DUMMY/DUMMY/issues/?'
|
22
41
|
end
|
23
42
|
end
|
24
43
|
|
@@ -82,7 +101,8 @@ Release <%= Time.now %>
|
|
82
101
|
<% end -%>
|
83
102
|
ERB
|
84
103
|
|
85
|
-
def build_pr_title_and_body(prs)
|
104
|
+
def build_pr_title_and_body(target_pr, prs)
|
105
|
+
target_pull_request = target_pr ? PullRequest.new(target_pr) : DummyPullRequest.new
|
86
106
|
pull_requests = prs.map { |pr| PullRequest.new(pr) }
|
87
107
|
|
88
108
|
template = DEFAULT_PR_TEMPLATE
|
@@ -243,53 +263,50 @@ end
|
|
243
263
|
### Create a release PR
|
244
264
|
|
245
265
|
say 'Searching for existing release pull requests...', :info
|
246
|
-
|
266
|
+
existing_pull_request = client.pull_requests(repository).find do |pr|
|
247
267
|
pr.head.ref == staging_branch && pr.base.ref == production_branch
|
248
268
|
end
|
269
|
+
create_mode = existing_pull_request.nil?
|
249
270
|
|
250
|
-
|
251
|
-
|
252
|
-
|
271
|
+
if @dry_run
|
272
|
+
pr_title, new_body = build_pr_title_and_body existing_pull_request, pull_requests
|
273
|
+
pr_body = create_mode ? new_body : merge_pr_body(existing_pull_request.body, new_body)
|
253
274
|
|
254
|
-
say '
|
255
|
-
say
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
if existing_release_pr
|
260
|
-
say "Updating release pull request ##{existing_release_pr.number}...", :info
|
275
|
+
say 'Dry-run. Not updating PR', :info
|
276
|
+
say pr_title, :notice
|
277
|
+
say pr_body, :notice
|
278
|
+
exit
|
279
|
+
end
|
261
280
|
|
262
|
-
|
281
|
+
pr_title, pr_body = nil, nil
|
282
|
+
target_pull_request = nil
|
263
283
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
repository, existing_release_pr.number, :title => pr_title, :body => merged_pr_body
|
272
|
-
)
|
284
|
+
if create_mode
|
285
|
+
created_pull_request = client.create_pull_request(
|
286
|
+
repository, production_branch, staging_branch, 'Preparing release pull request...', ''
|
287
|
+
)
|
288
|
+
unless created_pull_request
|
289
|
+
say 'Failed to create a new pull request', :error
|
290
|
+
exit 1
|
273
291
|
end
|
292
|
+
pr_title, pr_body = build_pr_title_and_body created_pull_request, pull_requests
|
293
|
+
target_pull_request = created_pull_request
|
274
294
|
else
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
say 'Dry-run. Not creating PR', :info
|
279
|
-
say pr_title, :notice
|
280
|
-
say pr_body, :notice
|
281
|
-
exit
|
282
|
-
else
|
283
|
-
release_pr = client.create_pull_request(
|
284
|
-
repository, production_branch, staging_branch, pr_title, pr_body
|
285
|
-
)
|
286
|
-
created = true
|
287
|
-
end
|
295
|
+
pr_title, new_body = build_pr_title_and_body existing_pull_request, pull_requests
|
296
|
+
pr_body = merge_pr_body(existing_pull_request.body, new_body)
|
297
|
+
target_pull_request = existing_pull_request
|
288
298
|
end
|
289
299
|
|
290
|
-
|
291
|
-
|
300
|
+
say 'Pull request body:', :debug
|
301
|
+
say pr_body, :debug
|
302
|
+
|
303
|
+
updated_pull_request = client.update_pull_request(
|
304
|
+
repository, target_pull_request.number, :title => pr_title, :body => pr_body
|
305
|
+
)
|
306
|
+
|
307
|
+
unless updated_pull_request
|
308
|
+
say 'Failed to update a pull request', :error
|
292
309
|
exit 1
|
293
310
|
end
|
294
311
|
|
295
|
-
say "#{
|
312
|
+
say "#{create_mode ? 'Created' : 'Updated'} pull request: #{updated_pull_request.rels[:html].href}", :notice
|
data/git-pr-release.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "git-pr-release"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.5'
|
8
8
|
spec.authors = ["motemen"]
|
9
9
|
spec.email = ["motemen@gmail.com"]
|
10
10
|
spec.summary = 'Creates a release pull request'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-pr-release
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- motemen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|