cm
This commit is contained in:
parent
c8db84a4a5
commit
1dd82cddf4
|
@ -122,40 +122,74 @@ module GitHubChangelogGenerator
|
||||||
def get_filtered_pull_requests
|
def get_filtered_pull_requests
|
||||||
|
|
||||||
pull_requests = self.get_all_closed_pull_requests
|
pull_requests = self.get_all_closed_pull_requests
|
||||||
|
filtered_pull_requests = pull_requests
|
||||||
|
|
||||||
unless @options[:pull_request_labels].nil?
|
|
||||||
|
|
||||||
if @options[:verbose]
|
unless @options[:include_labels].nil?
|
||||||
puts 'Filter all pull requests by labels.'
|
filtered_pull_requests = pull_requests.select { |issue|
|
||||||
end
|
#add all labels from @options[:incluse_labels] array
|
||||||
|
(issue.labels.map { |label| label.name } & @options[:include_labels]).any?
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
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]
|
if @options[:verbose]
|
||||||
puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}"
|
puts "Filtered pull requests: #{filtered_pull_requests.count}"
|
||||||
end
|
|
||||||
return filtered_pull_requests
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pull_requests
|
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
|
end
|
||||||
|
|
||||||
def compund_changelog
|
def compund_changelog
|
||||||
|
|
|
@ -6,7 +6,7 @@ require_relative 'version'
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
class Parser
|
class Parser
|
||||||
def self.parse_options
|
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|
|
parser = OptionParser.new { |opts|
|
||||||
opts.banner = 'Usage: changelog_generator [options]'
|
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|
|
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
|
options[:exclude_labels] = list
|
||||||
end
|
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|
|
opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last|
|
||||||
options[:github_site] = last
|
options[:github_site] = last
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user