Merge branch 'new-features'
This commit is contained in:
commit
3797b3ac31
|
@ -85,7 +85,7 @@ class ChangelogGenerator
|
||||||
puts log
|
puts log
|
||||||
end
|
end
|
||||||
|
|
||||||
log += "\n\n* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
log += "\n\n\\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
||||||
|
|
||||||
output_filename = "#{@options[:output]}"
|
output_filename = "#{@options[:output]}"
|
||||||
File.open(output_filename, 'w') { |file| file.write(log) }
|
File.open(output_filename, 'w') { |file| file.write(log) }
|
||||||
|
@ -286,15 +286,25 @@ class ChangelogGenerator
|
||||||
|
|
||||||
def get_all_issues
|
def get_all_issues
|
||||||
all_issues = []
|
all_issues = []
|
||||||
@options[:labels].each { |label|
|
|
||||||
issues = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: label
|
issues_req = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
|
||||||
all_issues = all_issues.concat(issues.body)
|
|
||||||
}
|
filtered_issues = issues_req.body.select { |issues|
|
||||||
|
(issues.labels.map { |issue| issue.name} & @options[:labels]).any?
|
||||||
|
}
|
||||||
|
|
||||||
|
if @options[:add_issues_wo_labels]
|
||||||
|
issues_wo_labels = issues_req.body.select {
|
||||||
|
|issues| !issues.labels.map { |issue| issue.name}.any?
|
||||||
|
}
|
||||||
|
filtered_issues.concat(issues_wo_labels)
|
||||||
|
end
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Receive all closed issues with labels #{@options[:labels]}: #{all_issues.count} issues"
|
puts "Receive all closed issues with labels #{@options[:labels]}: #{all_issues.count} issues"
|
||||||
end
|
end
|
||||||
|
|
||||||
all_issues
|
filtered_issues
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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}
|
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 }
|
||||||
|
|
||||||
parser = OptionParser.new { |opts|
|
parser = OptionParser.new { |opts|
|
||||||
opts.banner = 'Usage: changelog_generator [options]'
|
opts.banner = 'Usage: changelog_generator [options]'
|
||||||
|
@ -20,12 +20,15 @@ class Parser
|
||||||
puts opts
|
puts opts
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
|
opts.on('-v', '--[no-]verbose', 'Run verbosely. Default is true') do |v|
|
||||||
options[:verbose] = v
|
options[:verbose] = v
|
||||||
end
|
end
|
||||||
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
|
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
|
||||||
options[:issues] = v
|
options[:issues] = v
|
||||||
end
|
end
|
||||||
|
opts.on('--[no-]issues-without-labels', 'Include closed issues without any labels to changelog. Default is true') do |v|
|
||||||
|
options[:add_issues_wo_labels] = v
|
||||||
|
end
|
||||||
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
|
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
|
||||||
options[:pulls] = v
|
options[:pulls] = v
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user