From f7a536d0eafb9e5badce12f8d10bf320f120bb5c Mon Sep 17 00:00:00 2001 From: Takashi Sakai Date: Wed, 23 May 2018 18:08:42 +0900 Subject: [PATCH 1/5] Add release summary section --- lib/github_changelog_generator/generator/entry.rb | 1 + lib/github_changelog_generator/generator/section.rb | 9 ++++++--- lib/github_changelog_generator/options.rb | 1 + lib/github_changelog_generator/parser.rb | 4 ++++ lib/github_changelog_generator/parser_file.rb | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/github_changelog_generator/generator/entry.rb b/lib/github_changelog_generator/generator/entry.rb index 97a9241b7..aeb0be529 100644 --- a/lib/github_changelog_generator/generator/entry.rb +++ b/lib/github_changelog_generator/generator/entry.rb @@ -123,6 +123,7 @@ def generate_body(pull_requests, issues) # @return [Array] Section objects. def default_sections [ + Section.new(name: "summary", prefix: "", labels: @options[:summary_labels], options: @options, body_only:true), 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), diff --git a/lib/github_changelog_generator/generator/section.rb b/lib/github_changelog_generator/generator/section.rb index 16958639b..ab3cb69a9 100644 --- a/lib/github_changelog_generator/generator/section.rb +++ b/lib/github_changelog_generator/generator/section.rb @@ -5,7 +5,7 @@ module GitHubChangelogGenerator # # @see GitHubChangelogGenerator::Entry class Section - attr_accessor :name, :prefix, :issues, :labels + attr_accessor :name, :prefix, :issues, :labels, :body_only def initialize(opts = {}) @name = opts[:name] @@ -13,6 +13,7 @@ def initialize(opts = {}) @labels = opts[:labels] || [] @issues = opts[:issues] || [] @options = opts[:options] || Options.new({}) + @body_only = opts[:body_only] || false end # Returns the content of a section. @@ -22,10 +23,11 @@ def generate_content content = "" if @issues.any? - content += "#{@prefix}\n\n" unless @options[:simple_list] + content += "#{@prefix}\n\n" unless @options[:simple_list] || @prefix.blank? @issues.each do |issue| merge_string = get_string_for_issue(issue) - content += "- #{merge_string}\n" + content += "- " unless @body_only + content += "#{merge_string}\n" end content += "\n" end @@ -54,6 +56,7 @@ def get_string_for_issue(issue) def issue_line_with_body(line, issue) return line if !@options[:issue_line_body] || issue["body"].blank? + return encapsulate_string(issue["body"]) if @body_only # get issue body till first line break body_paragraph = body_till_first_break(issue["body"]) # remove spaces from begining and end of the string diff --git a/lib/github_changelog_generator/options.rb b/lib/github_changelog_generator/options.rb index 8370d9be3..64d3b5f6b 100644 --- a/lib/github_changelog_generator/options.rb +++ b/lib/github_changelog_generator/options.rb @@ -63,6 +63,7 @@ class Options < SimpleDelegator simple_list since_tag ssl_ca_file + summary_labels token unreleased unreleased_label diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 90a7f07b2..cb5d7a2f2 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -131,6 +131,9 @@ 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("--summary-labels x,y,z", Array, 'Issues with these labels will be added to a new section, called "Release Summary". The section display only body of issues. Default is \'release-summary,summary\'.') do |list| + options[:summary_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,breaking\'.') do |list| options[:breaking_labels] = list end @@ -230,6 +233,7 @@ def self.default_options unreleased_label: "Unreleased", compare_link: true, exclude_labels: ["duplicate", "question", "invalid", "wontfix", "Duplicate", "Question", "Invalid", "Wontfix", "Meta: Exclude From Changelog"], + summary_labels: ["Release-summary", "release-summary", "Summary", "summary"], breaking_labels: ["backwards-incompatible", "Backwards incompatible", "breaking"], enhancement_labels: ["enhancement", "Enhancement", "Type: Enhancement"], bug_labels: ["bug", "Bug", "Type: Bug"], diff --git a/lib/github_changelog_generator/parser_file.rb b/lib/github_changelog_generator/parser_file.rb index 44044fafb..f6e91633d 100644 --- a/lib/github_changelog_generator/parser_file.rb +++ b/lib/github_changelog_generator/parser_file.rb @@ -67,7 +67,7 @@ def extract_pair(line) end KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels - breaking_labels enhancement_labels bug_labels + summary_labels breaking_labels enhancement_labels bug_labels deprecated_labels removed_labels security_labels issue_line_labels between_tags exclude_tags] KNOWN_INTEGER_KEYS = [:max_issues] From b0b38b3fd8d7885b251611305ff724ef389d289c Mon Sep 17 00:00:00 2001 From: Takashi Sakai Date: Thu, 24 May 2018 10:17:20 +0900 Subject: [PATCH 2/5] Add label option for release summary section --- lib/github_changelog_generator/generator/entry.rb | 2 +- lib/github_changelog_generator/options.rb | 1 + lib/github_changelog_generator/parser.rb | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/github_changelog_generator/generator/entry.rb b/lib/github_changelog_generator/generator/entry.rb index aeb0be529..27a54226e 100644 --- a/lib/github_changelog_generator/generator/entry.rb +++ b/lib/github_changelog_generator/generator/entry.rb @@ -123,7 +123,7 @@ def generate_body(pull_requests, issues) # @return [Array] Section objects. def default_sections [ - Section.new(name: "summary", prefix: "", labels: @options[:summary_labels], options: @options, body_only:true), + Section.new(name: "summary", prefix: @options[:summary_prefix], labels: @options[:summary_labels], options: @options, body_only:true), 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), diff --git a/lib/github_changelog_generator/options.rb b/lib/github_changelog_generator/options.rb index 64d3b5f6b..dee313b90 100644 --- a/lib/github_changelog_generator/options.rb +++ b/lib/github_changelog_generator/options.rb @@ -64,6 +64,7 @@ class Options < SimpleDelegator since_tag ssl_ca_file summary_labels + summary_prefix token unreleased unreleased_label diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index cb5d7a2f2..3c9be2585 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -56,6 +56,9 @@ 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("--summary-label [LABEL]", "Set up custom label for the release summary section. Default is \"\".") do |v| + options[:summary_prefix] = v + end opts.on("--breaking-label [LABEL]", "Set up custom label for the breaking changes section. Default is \"**Breaking changes:**\".") do |v| options[:breaking_prefix] = v end @@ -250,6 +253,7 @@ def self.default_options header: "# Changelog", merge_prefix: "**Merged pull requests:**", issue_prefix: "**Closed issues:**", + summary_prefix: "", breaking_prefix: "**Breaking changes:**", enhancement_prefix: "**Implemented enhancements:**", bug_prefix: "**Fixed bugs:**", From daf85ffe4e29fb2a9942ee5f49e815cbdd6230b3 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 24 May 2018 21:00:58 +0900 Subject: [PATCH 3/5] 'issue_line_body' option is unnecessary to add release summary section --- lib/github_changelog_generator/generator/section.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator/generator/section.rb b/lib/github_changelog_generator/generator/section.rb index ab3cb69a9..905a49959 100644 --- a/lib/github_changelog_generator/generator/section.rb +++ b/lib/github_changelog_generator/generator/section.rb @@ -55,8 +55,8 @@ def get_string_for_issue(issue) end def issue_line_with_body(line, issue) + return issue["body"] if @body_only && issue["body"].present? return line if !@options[:issue_line_body] || issue["body"].blank? - return encapsulate_string(issue["body"]) if @body_only # get issue body till first line break body_paragraph = body_till_first_break(issue["body"]) # remove spaces from begining and end of the string From 1be72cdbc7f7d5bcd46112ea96a43a7715fc9cf4 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sun, 27 May 2018 18:10:46 +0900 Subject: [PATCH 4/5] Change default option for 'summary-labels' --- lib/github_changelog_generator/parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 3c9be2585..8d6704820 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -236,7 +236,7 @@ def self.default_options unreleased_label: "Unreleased", compare_link: true, exclude_labels: ["duplicate", "question", "invalid", "wontfix", "Duplicate", "Question", "Invalid", "Wontfix", "Meta: Exclude From Changelog"], - summary_labels: ["Release-summary", "release-summary", "Summary", "summary"], + summary_labels: ["Release summary", "release-summary", "Summary", "summary"], breaking_labels: ["backwards-incompatible", "Backwards incompatible", "breaking"], enhancement_labels: ["enhancement", "Enhancement", "Type: Enhancement"], bug_labels: ["bug", "Bug", "Type: Bug"], From 52342f9ade42ce53f3fc3124c0de70ba162c76b6 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Sun, 27 May 2018 18:23:27 +0900 Subject: [PATCH 5/5] Add man page for release summary options --- man/git-generate-changelog.1 | 14 +++++++++++++- man/git-generate-changelog.1.html | 10 +++++++++- man/git-generate-changelog.md | 8 ++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/man/git-generate-changelog.1 b/man/git-generate-changelog.1 index 42431d98a..0fc5d4f78 100644 --- a/man/git-generate-changelog.1 +++ b/man/git-generate-changelog.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-GENERATE\-CHANGELOG" "1" "April 2018" "" "" +.TH "GIT\-GENERATE\-CHANGELOG" "1" "May 2018" "" "" . .SH "NAME" \fBgit\-generate\-changelog\fR \- Generate changelog from GitHub @@ -49,6 +49,12 @@ Output file\. To print to STDOUT instead, use blank as path\. Default is CHANGEL Optional base file to append generated changes to\. . .P +\-\-summary\-label [LABEL] +. +.P +Set up custom label for the release summary section\. Default is ""\. +. +.P \-\-breaking\-label [LABEL] . .P @@ -199,6 +205,12 @@ Of the labeled issues, only include the ones with the specified labels\. Issues with the specified labels will be excluded from changelog\. Default is \'duplicate,question,invalid,wontfix\'\. . .P +\-\-summary\-labels x,y,z +. +.P +Issues with these labels will be added to a new section, called "Release Summary"\. The section display only body of issues\. Default is \'Release summary,release\-summary,Summary,summary\'\. +. +.P \-\-breaking\-labels x,y,z . .P diff --git a/man/git-generate-changelog.1.html b/man/git-generate-changelog.1.html index 7256f37c0..298e7aea4 100644 --- a/man/git-generate-changelog.1.html +++ b/man/git-generate-changelog.1.html @@ -109,6 +109,10 @@

OPTIONS

Optional base file to append generated changes to.

+

--summary-label [LABEL]

+ +

Set up custom label for the release summary section. Default is "".

+

--breaking-label [LABEL]

Set up custom label for breaking changes section. Default is "Breaking changes:".

@@ -209,6 +213,10 @@

OPTIONS

Issues with the specified labels will be excluded from changelog. Default is 'duplicate,question,invalid,wontfix'.

+

--summary-labels x,y,z

+ +

Issues with these labels will be added to a new section, called "Release Summary". The section display only body of issues. Default is 'Release summary,release-summary,Summary,summary'.

+

--breaking-labels x,y,z

Issues with these labels will be added to a new section, called "Breaking changes". Default is 'backwards-incompatible,breaking'.

@@ -334,7 +342,7 @@

SEE ALSO

  1. -
  2. April 2018
  3. +
  4. May 2018
  5. git-generate-changelog(1)
diff --git a/man/git-generate-changelog.md b/man/git-generate-changelog.md index 473e82d69..2cbc27770 100644 --- a/man/git-generate-changelog.md +++ b/man/git-generate-changelog.md @@ -35,6 +35,10 @@ Automatically generate changelog from your tags, issues, labels and pull request Optional base file to append generated changes to. + --summary-label [LABEL] + + Set up custom label for the release summary section. Default is "". + --breaking-label [LABEL] Set up custom label for breaking changes section. Default is "**Breaking changes:**". @@ -135,6 +139,10 @@ Automatically generate changelog from your tags, issues, labels and pull request Issues with the specified labels will be excluded from changelog. Default is 'duplicate,question,invalid,wontfix'. + --summary-labels x,y,z + + Issues with these labels will be added to a new section, called "Release Summary". The section display only body of issues. Default is 'Release summary,release-summary,Summary,summary'. + --breaking-labels x,y,z Issues with these labels will be added to a new section, called "Breaking changes". Default is 'backwards-incompatible,breaking'.