Skip to content

Issue #558 Keepachangelog labels #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ See also Troubleshooting.
- Run this:

$ github_changelog_generator -u github_username -p github_project

or, on the 1.14.x (current stable release)

$ github_changelog_generator github_username/github_project


- For Github Enterprise repos, specify *both* `--github-site` and `--github-api` options:

Expand Down Expand Up @@ -177,7 +177,7 @@ You can look for params names from the [parser source code (#setup_parser)](http

## Features and advantages of this project

- Generate canonical, neat changelog file, followed by [basic changelog guidelines](http://keepachangelog.com) :gem:
- Generate canonical, neat changelog file, with default sections that follow [basic changelog guidelines](http://keepachangelog.com) :gem:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wording is clearer, and teaches what this is about way better.

- Optionally generate **Unreleased** changes (closed issues that have not released yet) :dizzy:
- **GitHub Enterprise support** via command line options! :factory:
- Flexible format **customization**:
Expand Down
5 changes: 4 additions & 1 deletion lib/github_changelog_generator/generator/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ def default_sections
[
Section.new(name: "breaking", prefix: @options[:breaking_prefix], labels: @options[:breaking_labels], options: @options),
Section.new(name: "enhancements", prefix: @options[:enhancement_prefix], labels: @options[:enhancement_labels], options: @options),
Section.new(name: "bugs", prefix: @options[:bug_prefix], labels: @options[:bug_labels], options: @options)
Section.new(name: "bugs", prefix: @options[:bug_prefix], labels: @options[:bug_labels], options: @options),
Section.new(name: "deprecated", prefix: @options[:deprecated_prefix], labels: @options[:deprecated_labels], options: @options),
Section.new(name: "removed", prefix: @options[:removed_prefix], labels: @options[:removed_labels], options: @options),
Section.new(name: "security", prefix: @options[:security_prefix], labels: @options[:security_labels], options: @options)
]
end

Expand Down
12 changes: 9 additions & 3 deletions lib/github_changelog_generator/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ class Options < SimpleDelegator
author
base
between_tags
breaking_labels
breaking_prefix
bug_labels
bug_prefix
cache_file
cache_log
compare_link
configure_sections
date_format
deprecated_labels
deprecated_prefix
due_tag
enhancement_labels
enhancement_prefix
breaking_labels
breaking_prefix
configure_sections
exclude_labels
exclude_tags
exclude_tags_regex
Expand All @@ -52,7 +54,11 @@ class Options < SimpleDelegator
pulls
release_branch
release_url
removed_labels
removed_prefix
require
security_labels
security_prefix
simple_list
since_tag
ssl_ca_file
Expand Down
48 changes: 36 additions & 12 deletions lib/github_changelog_generator/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ def self.setup_parser(options)
opts.on("-b", "--base [NAME]", "Optional base file to append generated changes to.") do |last|
options[:base] = last
end
opts.on("--bugs-label [LABEL]", "Setup custom label for bug-fixes section. Default is \"**Fixed bugs:**\"") do |v|
options[:bug_prefix] = v
opts.on("--breaking-label [LABEL]", "Setup custom label for the breaking changes section. Default is \"**Breaking changes:**\"") do |v|
options[:breaking_prefix] = v
end
opts.on("--enhancement-label [LABEL]", "Setup custom label for enhancements section. Default is \"**Implemented enhancements:**\"") do |v|
options[:enhancement_prefix] = v
end
opts.on("--breaking-label [LABEL]", "Setup custom label for the breaking changes section. Default is \"**Breaking changes:**\"") do |v|
options[:breaking_prefix] = v
opts.on("--bugs-label [LABEL]", "Setup custom label for bug-fixes section. Default is \"**Fixed bugs:**\"") do |v|
options[:bug_prefix] = v
end
opts.on("--deprecated-label [LABEL]", "Setup custom label for the deprecated changes section. Default is \"**Deprecated:**\"") do |v|
options[:deprecated_prefix] = v
end
opts.on("--removed-label [LABEL]", "Setup custom label for the removed changes section. Default is \"**Removed:**\"") do |v|
options[:removed_prefix] = v
end
opts.on("--security-label [LABEL]", "Setup custom label for the security changes section. Default is \"**Security fixes:**\"") do |v|
options[:security_prefix] = v
end
opts.on("--issues-label [LABEL]", "Setup custom label for closed-issues section. Default is \"**Closed issues:**\"") do |v|
options[:issue_prefix] = v
Expand Down Expand Up @@ -122,14 +131,23 @@ def self.setup_parser(options)
opts.on("--exclude-labels x,y,z", Array, "Issues with the specified labels will be excluded from changelog. Default is 'duplicate,question,invalid,wontfix'") do |list|
options[:exclude_labels] = list
end
opts.on("--bug-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Fixed bugs" section. Default is \'bug,Bug\'') do |list|
options[:bug_labels] = list
opts.on("--breaking-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Breaking changes". Default is \'backwards-incompatible\'') do |list|
options[:breaking_labels] = list
end
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("--breaking-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Breaking Changes". Default is \'backwards-incompatible\'') do |list|
options[:breaking_labels] = list
opts.on("--bug-labels x,y,z", Array, 'Issues with the specified labels will be always added to "Fixed bugs" section. Default is \'bug,Bug\'') do |list|
options[:bug_labels] = list
end
opts.on("--deprecated-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Deprecated". Default is \'deprecated,Deprecated\'') do |list|
options[:deprecated_labels] = list
end
opts.on("--removed-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Removed". Default is \'removed,Removed\'') do |list|
options[:removed_labels] = list
end
opts.on("--security-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Security fixes". Default is \'security,Security\'') do |list|
options[:security_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
Expand Down Expand Up @@ -211,10 +229,13 @@ def self.default_options
unreleased: true,
unreleased_label: "Unreleased",
compare_link: true,
enhancement_labels: ["enhancement", "Enhancement", "Type: Enhancement"],
bug_labels: ["bug", "Bug", "Type: Bug"],
exclude_labels: ["duplicate", "question", "invalid", "wontfix", "Duplicate", "Question", "Invalid", "Wontfix", "Meta: Exclude From Changelog"],
breaking_labels: %w[backwards-incompatible breaking],
enhancement_labels: ["enhancement", "Enhancement", "Type: Enhancement"],
bug_labels: ["bug", "Bug", "Type: Bug"],
deprecated_labels: ["deprecated", "Deprecated", "Type: Deprecated"],
removed_labels: ["removed", "Removed", "Type: Removed"],
security_labels: ["security", "Security", "Type: Security"],
configure_sections: {},
add_sections: {},
issue_line_labels: [],
Expand All @@ -225,9 +246,12 @@ def self.default_options
header: "# Changelog",
merge_prefix: "**Merged pull requests:**",
issue_prefix: "**Closed issues:**",
bug_prefix: "**Fixed bugs:**",
enhancement_prefix: "**Implemented enhancements:**",
breaking_prefix: "**Breaking changes:**",
enhancement_prefix: "**Implemented enhancements:**",
bug_prefix: "**Fixed bugs:**",
deprecated_prefix: "**Deprecated:**",
removed_prefix: "**Removed:**",
security_prefix: "**Security fixes:**",
http_cache: true,
require: []
)
Expand Down
6 changes: 4 additions & 2 deletions lib/github_changelog_generator/parser_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ def extract_pair(line)
[key.tr("-", "_").to_sym, value.gsub(/[\n\r]+/, "")]
end

KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels bug_labels
enhancement_labels breaking_labels issue_line_labels between_tags exclude_tags]
KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels
breaking_labels enhancement_labels bug_labels
deprecated_labels removed_labels security_labels
issue_line_labels between_tags exclude_tags]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny thing: thanks for keeping the lines short - Github diffs are rendered much better when the lines are shorter (~ 80 chars). Kudos!

KNOWN_INTEGER_KEYS = [:max_issues]

def convert_value(value, option_name)
Expand Down
Loading