Sort issues by tags

This commit is contained in:
Petr Korolev 2014-11-10 16:13:34 +02:00
parent 50dd7b2ed6
commit f0716771b5
2 changed files with 41 additions and 28 deletions

View File

@ -228,7 +228,7 @@ class ChangelogGenerator
# Generate pull requests: # Generate pull requests:
if pull_requests if pull_requests
pull_requests.each { |dict| pull_requests.each { |dict|
merge = "#{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/pull/#{dict[:number]})\n\n" merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
log += "- #{merge}" log += "- #{merge}"
} }
end end
@ -237,6 +237,22 @@ class ChangelogGenerator
if @options[:issues] if @options[:issues]
# Generate issues: # Generate issues:
if issues if issues
issues.sort! { |x, y|
if x.labels.any? && y.labels.any?
x.labels[0].name <=> y.labels[0].name
else
if x.labels.any?
1
else
if y.labels.any?
-1
else
0
end
end
end
}.reverse!
end
issues.each { |dict| issues.each { |dict|
is_bug = false is_bug = false
is_enhancement = false is_enhancement = false
@ -258,13 +274,10 @@ class ChangelogGenerator
intro = 'Implemented enhancement' intro = 'Implemented enhancement'
end end
merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/issues/#{dict[:number]})\n\n" merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
log += "- #{merge}" log += "- #{merge}"
} }
end end
end
log log
end end

View File

@ -3,7 +3,7 @@ require 'optparse'
class Parser class Parser
def self.parse_options def self.parse_options
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true } options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ' }
parser = OptionParser.new { |opts| parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]' opts.banner = 'Usage: changelog_generator [options]'