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
|
end
|
||||||
|
|
||||||
# @param [Array] issues List of issues on sub-section
|
# @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
|
# @return [String] Generate ready-to-go sub-section
|
||||||
def generate_sub_section(issues, prefix)
|
def generate_sub_section(issues, prefix)
|
||||||
log = ""
|
log = ""
|
||||||
|
@ -143,11 +143,23 @@ module GitHubChangelogGenerator
|
||||||
encapsulated_title = encapsulate_string issue["title"]
|
encapsulated_title = encapsulate_string issue["title"]
|
||||||
|
|
||||||
title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
|
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)
|
issue_line_with_user(title_with_number, issue)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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)
|
def issue_line_with_user(line, issue)
|
||||||
return line if !options[:author] || issue["pull_request"].nil?
|
return line if !options[:author] || issue["pull_request"].nil?
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ module GitHubChangelogGenerator
|
||||||
:http_cache,
|
:http_cache,
|
||||||
:include_labels,
|
:include_labels,
|
||||||
:issue_prefix,
|
:issue_prefix,
|
||||||
|
:issue_line_labels,
|
||||||
:issues,
|
:issues,
|
||||||
:max_issues,
|
:max_issues,
|
||||||
:merge_prefix,
|
: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|
|
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
|
options[:enhancement_labels] = list
|
||||||
end
|
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|
|
opts.on("--between-tags x,y,z", Array, "Change log will be filled only between specified tags") do |list|
|
||||||
options[:between_tags] = list
|
options[:between_tags] = list
|
||||||
end
|
end
|
||||||
|
@ -205,6 +208,7 @@ module GitHubChangelogGenerator
|
||||||
enhancement_labels: %w(enhancement Enhancement),
|
enhancement_labels: %w(enhancement Enhancement),
|
||||||
bug_labels: %w(bug Bug),
|
bug_labels: %w(bug Bug),
|
||||||
exclude_labels: %w(duplicate question invalid wontfix Duplicate Question Invalid Wontfix),
|
exclude_labels: %w(duplicate question invalid wontfix Duplicate Question Invalid Wontfix),
|
||||||
|
issue_line_labels: [],
|
||||||
max_issues: nil,
|
max_issues: nil,
|
||||||
simple_list: false,
|
simple_list: false,
|
||||||
verbose: true,
|
verbose: true,
|
||||||
|
|
|
@ -66,7 +66,7 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
KNOWN_ARRAY_KEYS = [:exclude_labels, :include_labels, :bug_labels,
|
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]
|
KNOWN_INTEGER_KEYS = [:max_issues]
|
||||||
|
|
||||||
def convert_value(value, option_name)
|
def convert_value(value, option_name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user