git-pr-release 0.1.5 → 0.2.0

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: a3858360e38c1b2f4ef52fa613997e282328729b
4
- data.tar.gz: bcba7c5512fad71b320fbf35ac229380e51375f5
3
+ metadata.gz: 6be0d371bb9b42f9b5adf6da8f552247c27a7b9f
4
+ data.tar.gz: 541beb26f84a5b099e09e5d9ef80944572d8b5de
5
5
  SHA512:
6
- metadata.gz: c26c855c4bf0b737a4158d81efebcad0e67aa7459c09b6cd3301570269c3bddb24887d156ffcb1022d29b6541bde96c1ef104f05cd25d0bf82c5483c5fc3022c
7
- data.tar.gz: afa4072c7d4dcafa9d379db140f1b36ebe0778b2453a979b1f07e261d4830e9d71becbf76186e692a6c54896bfd4959ba71cc1bcf3e5e5cd771d19bcf59f0023
6
+ metadata.gz: 5abfbceb6829666f581b7a276cc80963cb6a5911525b2155daf9e7b492be4d98dc11aaefb8265b94239ae34d4203c0bc8eee97a117a2c9628ae475231ddfdca2
7
+ data.tar.gz: 67761b280acfede69804aaa8aa4d48cf21c1a18e604abfb7aea289959fc32a0fd6bfe2de7774bd4f588d7fb73e6040642d3503ed8931587f3a360dbdf134737b
@@ -111,7 +111,7 @@ Release <%= Time.now %>
111
111
  <% end -%>
112
112
  ERB
113
113
 
114
- def build_pr_title_and_body(release_pr, merged_prs)
114
+ def build_pr_title_and_body(release_pr, merged_prs, changed_files)
115
115
  release_pull_request = target_pull_request = release_pr ? PullRequest.new(release_pr) : DummyPullRequest.new
116
116
  merged_pull_requests = pull_requests = merged_prs.map { |pr| PullRequest.new(pr) }
117
117
 
@@ -127,10 +127,11 @@ def build_pr_title_and_body(release_pr, merged_prs)
127
127
  content.split(/\n/, 2)
128
128
  end
129
129
 
130
- def dump_result_as_json(release_pr, merged_prs)
130
+ def dump_result_as_json(release_pr, merged_prs, changed_files)
131
131
  puts( {
132
132
  :release_pull_request => (release_pr ? PullRequest.new(release_pr) : DummyPullRequest.new).to_hash,
133
- :merged_pull_requests => merged_prs.map { |pr| PullRequest.new(pr).to_hash }
133
+ :merged_pull_requests => merged_prs.map { |pr| PullRequest.new(pr).to_hash },
134
+ :changed_files => changed_files.map { |file| file.to_hash }
134
135
  }.to_json )
135
136
  end
136
137
 
@@ -223,6 +224,14 @@ def host_and_repository_and_scheme
223
224
  end
224
225
  end
225
226
 
227
+ # Fetch PR files of specified pull_request
228
+ def pull_request_files(client, pull_request)
229
+ return [] if pull_request.nil?
230
+
231
+ host, repository, scheme = host_and_repository_and_scheme
232
+ return client.pull_request_files repository, pull_request.number
233
+ end
234
+
226
235
  host, repository, scheme = host_and_repository_and_scheme
227
236
 
228
237
  if host
@@ -304,14 +313,17 @@ found_release_pr = client.pull_requests(repository).find do |pr|
304
313
  end
305
314
  create_mode = found_release_pr.nil?
306
315
 
316
+ # Fetch changed files of a release PR
317
+ changed_files = pull_request_files(client, found_release_pr)
318
+
307
319
  if @dry_run
308
- pr_title, new_body = build_pr_title_and_body found_release_pr, merged_prs
320
+ pr_title, new_body = build_pr_title_and_body found_release_pr, merged_prs, changed_files
309
321
  pr_body = create_mode ? new_body : merge_pr_body(found_release_pr.body, new_body)
310
322
 
311
323
  say 'Dry-run. Not updating PR', :info
312
324
  say pr_title, :notice
313
325
  say pr_body, :notice
314
- dump_result_as_json( found_release_pr, merged_prs ) if @json
326
+ dump_result_as_json( found_release_pr, merged_prs, changed_files ) if @json
315
327
  exit 0
316
328
  end
317
329
 
@@ -326,10 +338,11 @@ if create_mode
326
338
  say 'Failed to create a new pull request', :error
327
339
  exit 2
328
340
  end
329
- pr_title, pr_body = build_pr_title_and_body created_pr, merged_prs
341
+ changed_files = pull_request_files(client, created_pr) # Refetch changed files from created_pr
342
+ pr_title, pr_body = build_pr_title_and_body created_pr, merged_prs, changed_files
330
343
  release_pr = created_pr
331
344
  else
332
- pr_title, new_body = build_pr_title_and_body found_release_pr, merged_prs
345
+ pr_title, new_body = build_pr_title_and_body found_release_pr, merged_prs, changed_files
333
346
  pr_body = merge_pr_body(found_release_pr.body, new_body)
334
347
  release_pr = found_release_pr
335
348
  end
@@ -360,4 +373,4 @@ if not labels.nil? and not labels.empty?
360
373
  end
361
374
 
362
375
  say "#{create_mode ? 'Created' : 'Updated'} pull request: #{updated_pull_request.rels[:html].href}", :notice
363
- dump_result_as_json( release_pr, merged_prs ) if @json
376
+ dump_result_as_json( release_pr, merged_prs, changed_files ) if @json
@@ -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.1.5'
7
+ spec.version = '0.2.0'
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.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - motemen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit