From 9b8291ab69cb5d58ef46c0a48e264471c5dd464c Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 21:50:33 +0200 Subject: [PATCH 1/7] rename oprion --- lib/github_changelog_generator.rb | 4 ++-- lib/github_changelog_generator/parser.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index cf04249..1955a2e 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -504,7 +504,7 @@ module GitHubChangelogGenerator filtered_issues = issues.select { |issue| #compare is there any labels from @options[:labels] array - (issue.labels.map { |label| label.name } & @options[:labels]).any? + (issue.labels.map { |label| label.name } & @options[:include_labels]).any? } @@ -518,7 +518,7 @@ module GitHubChangelogGenerator if @options[:verbose] - puts "Filtered issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count}" + puts "Filtered issues with labels #{@options[:include_labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count}" end filtered_issues diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 1da43ef..db73ef6 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,7 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} + options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :include_labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} parser = OptionParser.new { |opts| opts.banner = 'Usage: changelog_generator [options]' @@ -52,8 +52,8 @@ module GitHubChangelogGenerator opts.on('--[no-]compare-link', 'Include compare link between older version and newer version. Default is true') do |v| options[:compare_link] = v end - opts.on('--labels x,y,z', Array, 'Issues with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list| - options[:labels] = list + opts.on('--include-labels x,y,z', Array, 'Issues with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list| + options[:include_labels] = list end opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list| options[:pull_request_labels] = list From 48e3a7525193e289810cbd8d6136f776226c4f89 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 22:08:10 +0200 Subject: [PATCH 2/7] implement eclude labels feature. Fix #52. --- lib/CHANGELOG.md | 2 -- lib/github_changelog_generator.rb | 18 ++++++++++++++---- lib/github_changelog_generator/parser.rb | 7 +++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 8fa7da4..70e44fc 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -5,8 +5,6 @@ - *Merged pull-request:* Implement filtering of Pull Requests by milestones [\#50](https://github.com/skywinder/Github-Changelog-Generator/pull/50) ([skywinder](https://github.com/skywinder)) -- *Implemented enhancement:* Add support for forked repo \(to extend changelog with parent's changes\) [\#21](https://github.com/skywinder/Github-Changelog-Generator/issues/21) - ## [1.2.8](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.8) (2015-02-17) [Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.7...1.2.8) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 1955a2e..d9017ac 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -502,11 +502,21 @@ module GitHubChangelogGenerator x.pull_request == nil } - filtered_issues = issues.select { |issue| - #compare is there any labels from @options[:labels] array - (issue.labels.map { |label| label.name } & @options[:include_labels]).any? - } + filtered_issues = [] + unless @options[:include_labels].nil? + filtered_issues = issues.select { |issue| + #add all labels from @options[:incluse_labels] array + (issue.labels.map { |label| label.name } & @options[:include_labels]).any? + } + end + + unless @options[:exclude_labels].nil? + filtered_issues = filtered_issues.select { |issue| + #delete all labels from @options[:exclude_labels] array + !(issue.labels.map { |label| label.name } & @options[:exclude_labels]).any? + } + end if @options[:add_issues_wo_labels] issues_wo_labels = issues.select { diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index db73ef6..487118c 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,7 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :include_labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} + options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :include_labels => %w(bug enhancement), :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} parser = OptionParser.new { |opts| opts.banner = 'Usage: changelog_generator [options]' @@ -52,9 +52,12 @@ module GitHubChangelogGenerator opts.on('--[no-]compare-link', 'Include compare link between older version and newer version. Default is true') do |v| options[:compare_link] = v end - opts.on('--include-labels x,y,z', Array, 'Issues with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list| + opts.on('--include-labels x,y,z', Array, 'Issues only with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list| options[:include_labels] = list end + opts.on('--exclude-labels x,y,z', Array, 'Issues with that labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list| + options[:exclude_labels] = list + end opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list| options[:pull_request_labels] = list end From 1d7f09e9bbfa065d91ede4e0eb88bff79c33e194 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 22:11:11 +0200 Subject: [PATCH 3/7] change include to exclude default rule --- lib/github_changelog_generator.rb | 2 +- lib/github_changelog_generator/parser.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index d9017ac..4455c68 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -502,7 +502,7 @@ module GitHubChangelogGenerator x.pull_request == nil } - filtered_issues = [] + filtered_issues = issues unless @options[:include_labels].nil? filtered_issues = issues.select { |issue| diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 487118c..fd27939 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,7 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :include_labels => %w(bug enhancement), :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} + options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} parser = OptionParser.new { |opts| opts.banner = 'Usage: changelog_generator [options]' From 563ddb7f309b375c3f87d495f360437ea82dc409 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 22:21:00 +0200 Subject: [PATCH 4/7] refactoring --- lib/github_changelog_generator.rb | 61 +++++++++++++----------- lib/github_changelog_generator/parser.rb | 7 ++- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 4455c68..3739ab4 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -40,7 +40,7 @@ module GitHubChangelogGenerator @all_tags = self.get_all_tags @pull_requests = self.get_filtered_pull_requests if @options[:issues] - @issues = self.get_all_issues + @issues = self.get_filtered_issues fetch_event_for_issues(@issues) detect_actual_closed_dates else @@ -474,33 +474,9 @@ module GitHubChangelogGenerator @tag_times_hash[tag_name['name']] = Time.parse(time_string) end - def get_all_issues + def get_filtered_issues - if @options[:verbose] - print "Fetching closed issues...\r" - end - - response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil - - issues = [] - page_i = 0 - count_pages = response.count_pages - response.each_page do |page| - page_i += PER_PAGE_NUMBER - print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r" - issues.concat(page) - end - - print " \r" - - if @options[:verbose] - puts "Received issues: #{issues.count}" - end - - # remove pull request from issues: - issues.select! { |x| - x.pull_request == nil - } + issues = self.get_all_issues filtered_issues = issues @@ -528,13 +504,42 @@ module GitHubChangelogGenerator if @options[:verbose] - puts "Filtered issues with labels #{@options[:include_labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count}" + puts "Filtered issues: #{filtered_issues.count}" end filtered_issues end + def get_all_issues + if @options[:verbose] + print "Fetching closed issues...\r" + end + + response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil + + issues = [] + page_i = 0 + count_pages = response.count_pages + response.each_page do |page| + page_i += PER_PAGE_NUMBER + print "Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r" + issues.concat(page) + end + + print " \r" + + if @options[:verbose] + puts "Received issues: #{issues.count}" + end + + # remove pull request from issues: + issues.select! { |x| + x.pull_request == nil + } + issues + end + def fetch_event_for_issues(filtered_issues) if @options[:verbose] print "Fetching events for issues: 0/#{filtered_issues.count}\r" diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index fd27939..4b719a5 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,7 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} + options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :add_pr_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} parser = OptionParser.new { |opts| opts.banner = 'Usage: changelog_generator [options]' @@ -31,9 +31,12 @@ module GitHubChangelogGenerator opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v| options[:issues] = v end - opts.on('--[no-]issues-wo-labels', 'Include closed issues without any labels to changelog. Default is true') do |v| + opts.on('--[no-]issues-wo-labels', 'Include closed issues without labels to changelog. Default is true') do |v| options[:add_issues_wo_labels] = v end + opts.on('--[no-]pr-wo-labels', 'Include pull requests without labels to changelog. Default is true') do |v| + options[:add_pr_wo_labels] = v + end opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v| options[:pulls] = v end From c8db84a4a5286218bca8ca9e7ffa48fb5b23e387 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 22:29:30 +0200 Subject: [PATCH 5/7] prettify output: display tag fetching status --- lib/github_changelog_generator.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 3739ab4..27c3607 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -192,8 +192,8 @@ module GitHubChangelogGenerator output_filename = "#{@options[:output]}" File.open(output_filename, 'w') { |file| file.write(log) } - - puts "Done! Generated log placed in #{`pwd`.strip!}/#{output_filename}" + puts 'Done!' + puts "Generated log placed in #{`pwd`.strip!}/#{output_filename}" end @@ -201,17 +201,30 @@ module GitHubChangelogGenerator log = '' if @options[:verbose] - puts "Fetching tags dates.." + print "Fetching tags dates..\r" end # Async fetching tags: threads = [] + i = 0 + all = @all_tags.count @all_tags.each { |tag| # explicit set @tag_times_hash to write data safety. - threads << Thread.new { self.get_time_of_tag(tag, @tag_times_hash) } + threads << Thread.new { + self.get_time_of_tag(tag, @tag_times_hash) + if @options[:verbose] + i+=1 + print "Fetching tags dates: #{i+1}/#{all}\r" + end + + } } + threads.each { |thr| thr.join } + if @options[:verbose] + puts 'Fetching tags: Done!' + end if @options[:verbose] puts "Sorting tags.." end From 1dd82cddf4580dc74674d0e43f33fcb3f23fb2ff Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 22:54:12 +0200 Subject: [PATCH 6/7] cm --- lib/github_changelog_generator.rb | 92 ++++++++++++++++-------- lib/github_changelog_generator/parser.rb | 5 +- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 27c3607..3c497a1 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -122,40 +122,74 @@ module GitHubChangelogGenerator def get_filtered_pull_requests pull_requests = self.get_all_closed_pull_requests + filtered_pull_requests = pull_requests - unless @options[:pull_request_labels].nil? - if @options[:verbose] - puts 'Filter all pull requests by labels.' - end - - filtered_pull_requests = pull_requests.select { |pull_request| - #fetch this issue to get labels array - issue = @github.issues.get @options[:user], @options[:project], pull_request.number - - #compare is there any labels from @options[:labels] array - issue_without_labels = !issue.labels.map { |label| label.name }.any? - - if @options[:verbose] - puts "Filter request \##{issue.number}." - end - - if @options[:pull_request_labels].any? - select_by_label = (issue.labels.map { |label| label.name } & @options[:pull_request_labels]).any? - else - select_by_label = false - end - - select_by_label | issue_without_labels + unless @options[:include_labels].nil? + filtered_pull_requests = pull_requests.select { |issue| + #add all labels from @options[:incluse_labels] array + (issue.labels.map { |label| label.name } & @options[:include_labels]).any? } - - if @options[:verbose] - puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}" - end - return filtered_pull_requests end - pull_requests + unless @options[:exclude_labels].nil? + filtered_pull_requests = filtered_pull_requests.select { |issue| + #delete all labels from @options[:exclude_labels] array + !(issue.labels.map { |label| label.name } & @options[:exclude_labels]).any? + } + end + + if @options[:add_issues_wo_labels] + issues_wo_labels = pull_requests.select { + # add issues without any labels + |issue| !issue.labels.map { |label| label.name }.any? + } + filtered_pull_requests.concat(issues_wo_labels) + end + + + if @options[:verbose] + puts "Filtered pull requests: #{filtered_pull_requests.count}" + end + + filtered_pull_requests + # + # # + # + # + # unless @options[:pull_request_labels].nil? + # + # if @options[:verbose] + # puts 'Filter all pull requests by labels.' + # end + # + # filtered_pull_requests = filtered_pull_requests.select { |pull_request| + # #fetch this issue to get labels array + # issue = @github.issues.get @options[:user], @options[:project], pull_request.number + # + # #compare is there any labels from @options[:labels] array + # issue_without_labels = !issue.labels.map { |label| label.name }.any? + # + # if @options[:verbose] + # puts "Filter request \##{issue.number}." + # end + # + # if @options[:pull_request_labels].any? + # select_by_label = (issue.labels.map { |label| label.name } & @options[:pull_request_labels]).any? + # else + # select_by_label = false + # end + # + # select_by_label | issue_without_labels + # } + # + # if @options[:verbose] + # puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}" + # end + # return filtered_pull_requests + # end + # + # filtered_pull_requests end def compund_changelog diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 4b719a5..a22ef1c 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,7 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :add_pr_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} + options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :add_pr_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} parser = OptionParser.new { |opts| opts.banner = 'Usage: changelog_generator [options]' @@ -61,9 +61,6 @@ module GitHubChangelogGenerator opts.on('--exclude-labels x,y,z', Array, 'Issues with that labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list| options[:exclude_labels] = list end - opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list| - options[:pull_request_labels] = list - end opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last| options[:github_site] = last end From c4f91f55ffc62f83c82bdbbbcd35620f6eb378c7 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Wed, 18 Feb 2015 23:32:40 +0200 Subject: [PATCH 7/7] Fix #44. --- lib/CHANGELOG.md | 2 -- lib/github_changelog_generator.rb | 36 +++++++++++++++++------- lib/github_changelog_generator/parser.rb | 1 + 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 70e44fc..3514157 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -76,8 +76,6 @@ - *Merged pull-request:* Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder)) -- *Merged pull-request:* Test Pull-Request SHOULD NOT APPEAR IN LOG! [\#26](https://github.com/skywinder/Github-Changelog-Generator/pull/26) ([skywinder](https://github.com/skywinder)) - - *Merged pull-request:* Add ability to insert authors of pull-requests \(--\[no-\]author option\) [\#25](https://github.com/skywinder/Github-Changelog-Generator/pull/25) ([skywinder](https://github.com/skywinder)) - *Merged pull-request:* Don't receive issues in case of --no-isses flag specied [\#24](https://github.com/skywinder/Github-Changelog-Generator/pull/24) ([skywinder](https://github.com/skywinder)) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 3c497a1..a3e9c47 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -38,7 +38,15 @@ module GitHubChangelogGenerator @generator = Generator.new(@options) @all_tags = self.get_all_tags - @pull_requests = self.get_filtered_pull_requests + @issues, @pull_requests = self.fetch_issues_and_pull_requests + + if @options[:pulls] + @pull_requests = self.get_filtered_pull_requests + self.fetch_merged_at_pull_requests + else + @pull_requests = [] + end + if @options[:issues] @issues = self.get_filtered_issues fetch_event_for_issues(@issues) @@ -96,7 +104,7 @@ module GitHubChangelogGenerator %x[#{exec_cmd}] end - def get_all_closed_pull_requests + def fetch_merged_at_pull_requests if @options[:verbose] print "Fetching pull requests...\r" end @@ -116,12 +124,17 @@ module GitHubChangelogGenerator puts "Received pull requests: #{pull_requests.count}" end - pull_requests + @pull_requests.each{|pr| + fetched_pr = pull_requests.find{ |fpr| + fpr.number == pr.number } + pr[:merged_at] = fetched_pr[:merged_at] + pull_requests.delete(fetched_pr) + } end def get_filtered_pull_requests - pull_requests = self.get_all_closed_pull_requests + pull_requests = @pull_requests filtered_pull_requests = pull_requests @@ -144,7 +157,7 @@ module GitHubChangelogGenerator # add issues without any labels |issue| !issue.labels.map { |label| label.name }.any? } - filtered_pull_requests.concat(issues_wo_labels) + filtered_pull_requests |= issues_wo_labels end @@ -523,7 +536,7 @@ module GitHubChangelogGenerator def get_filtered_issues - issues = self.get_all_issues + issues = @issues filtered_issues = issues @@ -546,7 +559,7 @@ module GitHubChangelogGenerator # add issues without any labels |issue| !issue.labels.map { |label| label.name }.any? } - filtered_issues.concat(issues_wo_labels) + filtered_issues |= issues_wo_labels end @@ -558,7 +571,7 @@ module GitHubChangelogGenerator end - def get_all_issues + def fetch_issues_and_pull_requests if @options[:verbose] print "Fetching closed issues...\r" end @@ -581,10 +594,13 @@ module GitHubChangelogGenerator end # remove pull request from issues: - issues.select! { |x| + issues_wo_pr = issues.select { |x| x.pull_request == nil } - issues + pull_requests = issues.select { |x| + x.pull_request != nil + } + return issues_wo_pr, pull_requests end def fetch_event_for_issues(filtered_issues) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index a22ef1c..2f21aca 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,6 +6,7 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options + # :include_labels => %w(bug enhancement), options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :add_pr_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true} parser = OptionParser.new { |opts|