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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 694fe3719f59b5f9f4a2798de0076b8e29200b9b
4
- data.tar.gz: 394d44150cdccadaa2443e214f4b69bfe3f66f83
3
+ metadata.gz: 6bc50424a98694a90f526c8685e4ea743a46b9d6
4
+ data.tar.gz: 934bf70ff7c35846b4d525023e20593d9dbd2385
5
5
  SHA512:
6
- metadata.gz: c21ff349e9e5d0e62ab68e2a37d30933bd607ba61811e9a60c4acbcb337afdb347b733517beeb2d9fc145470953bc7d987dcf3e360f2f1375280c7d270c9afcb
7
- data.tar.gz: adc973a3068dbe13cba52fbfd5de3ad67c4ea3960780a6243c61746d42f873c5d33645cc66c4f680784eeba9ec9a9b1fc9dd58e37bf87f260f00840667517829
6
+ metadata.gz: b8110e2381e583f4cdf913d02b85a6b2978cf0344b0b6a5791980e26bcd26bec6bc1f3398d199d93b4dfba1cbaaa312de0985ca04d1cbc16f60aa79a5cfeb8f5
7
+ data.tar.gz: 7243843af08eba2a5bacf9f72bdc0b1ffc6a5f6eb598ab0d2b0a7af711b997b95d6e7179adc61ae961029d530365a8888cca0b7018d7bfd7b584b5ad4b8aebce
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- git-pr-release
1
+ git-pr-release <a href="http://badge.fury.io/rb/git-pr-release"><img src="https://badge.fury.io/rb/git-pr-release@2x.png" alt="Gem Version" height="18"></a>
2
2
  ==============
3
3
 
4
4
  Creates a pull request which summarizes feature branches that are to be
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}" + (pr.assignee ? " @#{pr.assignee.login}" : '')
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
- existing_release_pr = client.pull_requests(repository).find do |pr|
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
- created = false
251
-
252
- pr_title, pr_body = build_pr_title_and_body pull_requests
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 'Pull request body:', :debug
255
- say pr_body, :debug
256
-
257
- release_pr = nil
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
- merged_pr_body = merge_pr_body existing_release_pr.body, pr_body
281
+ pr_title, pr_body = nil, nil
282
+ target_pull_request = nil
263
283
 
264
- if @dry_run
265
- say 'Dry-run. Not updating PR', :info
266
- say pr_title, :notice
267
- say merged_pr_body, :notice
268
- exit
269
- else
270
- release_pr = client.update_pull_request(
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
- say 'Creating release pull request...', :info
276
-
277
- if @dry_run
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
- unless release_pr
291
- say 'No pull request found/created', :error
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 "#{created ? 'Created' : 'Updated'} pull request: #{release_pr.rels[:html].href}", :notice
312
+ say "#{create_mode ? 'Created' : 'Updated'} pull request: #{updated_pull_request.rels[:html].href}", :notice
@@ -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.4'
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
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-05 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit