Merge branch 'develop'

This commit is contained in:
Petr Korolev 2015-01-15 23:30:00 +01:00
commit 6efa421816
3 changed files with 49 additions and 4 deletions

View File

@ -231,6 +231,11 @@ module GitHubChangelogGenerator
def generate_log_between_tags(older_tag, newer_tag)
if newer_tag.nil?
puts "Can't find tag -> terminate"
exit 1
end
newer_tag_time = self.get_time_of_tag(newer_tag)
newer_tag_name = newer_tag['name']
@ -243,6 +248,43 @@ module GitHubChangelogGenerator
filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
end
if @options[:filter_issues_by_milestone]
#delete excess irrelevant issues (according milestones)
filtered_issues.select! { |issue|
if issue.milestone.nil?
true
else
#check, that this milestone in tag list:
milestone_is_tag = @all_tags.find { |tag|
tag.name == issue.milestone.title
}
milestone_is_tag.nil?
end
}
#add missed issues (according milestones)
issues_to_add = @issues.select { |issue|
if issue.milestone.nil?
false
else
#check, that this milestone in tag list:
milestone_is_tag = @all_tags.find { |tag|
tag.name == issue.milestone.title
}
if milestone_is_tag.nil?
false
else
issue.milestone.title == newer_tag_name
end
end
}
filtered_issues |= issues_to_add
end
self.create_log(filtered_pull_requests, filtered_issues, newer_tag_name, newer_tag_time)
end

View File

@ -10,10 +10,10 @@ module GitHubChangelogGenerator
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
if @options[:author]
if !pull_request.user.nil?
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
else
if pull_request.user.nil?
merge += " ({Null user})\n\n"
else
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
end
else
merge += "\n\n"

View File

@ -6,7 +6,7 @@ require_relative 'version'
module GitHubChangelogGenerator
class Parser
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, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil}
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:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true}
parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]'
@ -37,6 +37,9 @@ module GitHubChangelogGenerator
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
options[:pulls] = v
end
opts.on('--[no-]filter-issues-by-milestone', 'Use milestone to detect when issue was resolved. Default is true') do |last|
options[:filter_issues_by_milestone] = last
end
opts.on('--[no-]author', 'Add author of pull-request in the end. Default is true') do |author|
options[:last] = author
end