diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-02-09 07:38:40 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-02-09 07:38:40 -0600 |
commit | 580c0bc7002a7d81ceee10184ef4ba70db9c6007 (patch) | |
tree | 797aabcbdbf1b6b4b5067319ce3d9955eb20ab6a /task/release.rake | |
parent | cfd66c99a10ac218bb6b8c2ef07659d5e347b41c (diff) | |
download | bundler-580c0bc7002a7d81ceee10184ef4ba70db9c6007.tar.gz |
[Release] Fix pulling PRs from milestoneseg-fix-milestone-release
Implement pagination
Account for the fact that only issues can be filtered by milestone, not PRs
Diffstat (limited to 'task/release.rake')
-rw-r--r-- | task/release.rake | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/task/release.rake b/task/release.rake index 03f1fd617d..9d31e2a36e 100644 --- a/task/release.rake +++ b/task/release.rake @@ -15,8 +15,21 @@ namespace :release do require "json" host = opts.fetch(:host) { "https://api.github.com/" } path = opts.fetch(:path) - response = Net::HTTP.get(URI.join(host, path)) - JSON.parse(response) + response = Net::HTTP.get_response(URI.join(host, path)) + + links = Hash[*(response["Link"] || "").split(", ").map do |link| + href, name = link.match(/<(.*?)>; rel="(\w+)"/).captures + + [name.to_sym, href] + end.flatten] + + parsed_response = JSON.parse(response.body) + + if n = links[:next] + parsed_response.concat gh_api_request(:host => host, :path => n) + end + + parsed_response end desc "Make a patch release with the PRs from master in the patch milestone" @@ -40,13 +53,12 @@ namespace :release do unless patch_milestone = milestones.find {|m| m["title"] == version } abort "failed to find #{version} milestone on GitHub" end - prs = gh_api_request(:path => "repos/bundler/bundler/pulls?milestone=#{patch_milestone["number"]}") + prs = gh_api_request(:path => "repos/bundler/bundler/issues?milestone=#{patch_milestone["number"]}&state=all") prs.map! do |pr| - unless pr["merged_at"] - abort "https://github.com/bundler/bundler/pull/#{pr["number"]} hasn't been merged yet!" - end + abort "#{pr["html_url"]} hasn't been closed yet!" unless pr["state"] == "closed" + next unless pr["pull_request"] pr["number"] - end + end.compact version_file = "lib/bundler/version.rb" version_contents = File.read(version_file) @@ -63,6 +75,8 @@ namespace :release do commits = `git log --oneline origin/master --`.split("\n").map {|l| l.split(/\s/, 2) }.reverse commits.select! {|_sha, message| message =~ /(Auto merge of|Merge pull request) ##{Regexp.union(*prs)}/ } + abort "Could not find commits for all PRs" unless commits.size == prs.size + unless system("git", "cherry-pick", "-x", "-m", "1", *commits.map(&:first)) abort unless system("zsh") end |