From 06a8fe816953b0186e965138d41bda648e1c813a Mon Sep 17 00:00:00 2001 From: Steve Gilvarry Date: Wed, 18 Nov 2015 16:56:27 +1100 Subject: [PATCH] Add release-branch option to filter the Pull Requests by those applied on a partcular release branch --- lib/github_changelog_generator/fetcher.rb | 7 ++++++- .../generator/generator_processor.rb | 6 ++++-- lib/github_changelog_generator/parser.rb | 3 +++ lib/github_changelog_generator/task.rb | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator/fetcher.rb b/lib/github_changelog_generator/fetcher.rb index fa81112..f203b8b 100644 --- a/lib/github_changelog_generator/fetcher.rb +++ b/lib/github_changelog_generator/fetcher.rb @@ -22,6 +22,7 @@ module GitHubChangelogGenerator github_options[:oauth_token] = @github_token unless @github_token.nil? github_options[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil? github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil? + @release_branch = @options[:release_branch] unless @options[:release_branch].nil? @github = check_github_response { Github.new github_options } end @@ -123,7 +124,11 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow def fetch_closed_pull_requests pull_requests = [] begin - response = @github.pull_requests.list @options[:user], @options[:project], state: "closed" + if @options[:release_branch].nil? + response = @github.pull_requests.list @options[:user], @options[:project], state: "closed" + else + response = @github.pull_requests.list @options[:user], @options[:project], state: "closed", base: @options[:release_branch] + end page_i = 0 count_pages = response.count_pages response.each_page do |page| diff --git a/lib/github_changelog_generator/generator/generator_processor.rb b/lib/github_changelog_generator/generator/generator_processor.rb index e264a90..ee9d560 100644 --- a/lib/github_changelog_generator/generator/generator_processor.rb +++ b/lib/github_changelog_generator/generator/generator_processor.rb @@ -178,8 +178,10 @@ module GitHubChangelogGenerator fetched_pr = closed_pull_requests.find do |fpr| fpr.number == pr.number end - pr[:merged_at] = fetched_pr[:merged_at] - closed_pull_requests.delete(fetched_pr) + unless fetched_pr.nil? + pr[:merged_at] = fetched_pr[:merged_at] + closed_pull_requests.delete(fetched_pr) + end end pull_requests.select! do |pr| diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 46ffdef..7918c3a 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -143,6 +143,9 @@ module GitHubChangelogGenerator opts.on("--future-release [RELEASE-VERSION]", "Put the unreleased changes in the specified release number.") do |future_release| options[:future_release] = future_release end + opts.on("--release-branch [RELEASE-BRANCH]", "Limit pull requests to the release branch, such as master or release") do |release_branch| + options[:release_branch] = release_branch + end opts.on("--[no-]verbose", "Run verbosely. Default is true") do |v| options[:verbose] = v end diff --git a/lib/github_changelog_generator/task.rb b/lib/github_changelog_generator/task.rb index e87f7f2..0dadbf4 100644 --- a/lib/github_changelog_generator/task.rb +++ b/lib/github_changelog_generator/task.rb @@ -16,7 +16,8 @@ module GitHubChangelogGenerator bug_labels enhancement_labels between_tags exclude_tags since_tag max_issues github_site github_endpoint simple_list - future_release verbose release_url base ) + future_release release_branch verbose release_url + base ) OPTIONS.each do |o| attr_accessor o.to_sym