Add option to show selected labels in the issue line: --issue-line-labels
This commit is contained in:
parent
9eb8c93019
commit
1fd341d9bf
|
@ -25,7 +25,7 @@ module GitHubChangelogGenerator
|
|||
end
|
||||
|
||||
# @param [Array] issues List of issues on sub-section
|
||||
# @param [String] prefix Nae of sub-section
|
||||
# @param [String] prefix Name of sub-section
|
||||
# @return [String] Generate ready-to-go sub-section
|
||||
def generate_sub_section(issues, prefix)
|
||||
log = ""
|
||||
|
@ -143,11 +143,23 @@ module GitHubChangelogGenerator
|
|||
encapsulated_title = encapsulate_string issue["title"]
|
||||
|
||||
title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
|
||||
if options[:issue_line_labels].present?
|
||||
title_with_number = "#{title_with_number}{line_labels_for(issue)}"
|
||||
end
|
||||
issue_line_with_user(title_with_number, issue)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def line_labels_for(issue)
|
||||
labels = if options[:issue_line_labels] == ["ALL"]
|
||||
issue["labels"]
|
||||
else
|
||||
issue["labels"].select { |label| options[:issue_line_labels].include?(label["name"]) }
|
||||
end
|
||||
labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
|
||||
end
|
||||
|
||||
def issue_line_with_user(line, issue)
|
||||
return line if !options[:author] || issue["pull_request"].nil?
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ module GitHubChangelogGenerator
|
|||
:http_cache,
|
||||
:include_labels,
|
||||
:issue_prefix,
|
||||
:issue_line_labels,
|
||||
:issues,
|
||||
:max_issues,
|
||||
:merge_prefix,
|
||||
|
|
|
@ -125,6 +125,9 @@ module GitHubChangelogGenerator
|
|||
opts.on("--enhancement-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Implemented enhancements" section. Default is \'enhancement,Enhancement\'') do |list|
|
||||
options[:enhancement_labels] = list
|
||||
end
|
||||
opts.on("--issue-line-labels x,y,z", Array, 'The specified labels will be shown in brackets next to each matching issue. Use "ALL" to show all labels. Default is [].') do |list|
|
||||
options[:issue_line_labels] = list
|
||||
end
|
||||
opts.on("--between-tags x,y,z", Array, "Change log will be filled only between specified tags") do |list|
|
||||
options[:between_tags] = list
|
||||
end
|
||||
|
@ -205,6 +208,7 @@ module GitHubChangelogGenerator
|
|||
enhancement_labels: %w(enhancement Enhancement),
|
||||
bug_labels: %w(bug Bug),
|
||||
exclude_labels: %w(duplicate question invalid wontfix Duplicate Question Invalid Wontfix),
|
||||
issue_line_labels: [],
|
||||
max_issues: nil,
|
||||
simple_list: false,
|
||||
verbose: true,
|
||||
|
|
|
@ -66,7 +66,7 @@ module GitHubChangelogGenerator
|
|||
end
|
||||
|
||||
KNOWN_ARRAY_KEYS = [:exclude_labels, :include_labels, :bug_labels,
|
||||
:enhancement_labels, :between_tags, :exclude_tags]
|
||||
:enhancement_labels, :issue_line_labels, :between_tags, :exclude_tags]
|
||||
KNOWN_INTEGER_KEYS = [:max_issues]
|
||||
|
||||
def convert_value(value, option_name)
|
||||
|
|
Loading…
Reference in New Issue
Block a user