diff --git a/lib/github_changelog_generator/argv_parser.rb b/lib/github_changelog_generator/argv_parser.rb index e62bae72..a38e3ee1 100755 --- a/lib/github_changelog_generator/argv_parser.rb +++ b/lib/github_changelog_generator/argv_parser.rb @@ -205,6 +205,9 @@ def parser opts.on("--[no-]verbose", "Run verbosely. Default is true.") do |v| options[:verbose] = v end + opts.on("--contributors-on-own-line", "Place contributors on their own line in italics. Default is false.") do |v| + options[:verbose] = v + end opts.on("-v", "--version", "Print version number.") do |_v| puts "Version: #{GitHubChangelogGenerator::VERSION}" exit diff --git a/lib/github_changelog_generator/generator/section.rb b/lib/github_changelog_generator/generator/section.rb index f06c8e38..12007c90 100644 --- a/lib/github_changelog_generator/generator/section.rb +++ b/lib/github_changelog_generator/generator/section.rb @@ -47,6 +47,7 @@ def generate_content merge_string = get_string_for_issue(issue) content += "- " unless @body_only content += "#{merge_string}\n" + content += "\n" if @options[:contributors_on_own_line] && issue["pull_request"] && issue != @issues.last end content += "\n" end @@ -97,14 +98,18 @@ def body_till_first_break(body) def issue_line_with_user(line, issue) return line if !@options[:author] || issue["pull_request"].nil? - user = issue["user"] + user = user(issue["user"]) return "#{line} ({Null user})" unless user - if @options[:usernames_as_github_logins] - "#{line} (@#{user['login']})" - else - "#{line} ([#{user['login']}](#{user['html_url']}))" - end + return "#{line} (#{user})" unless @options[:contributors_on_own_line] + + "#{line}\n\n *#{user}*" + end + + def user(user) + return "{Null user}" unless user + + @options[:usernames_as_github_logins] ? "@#{user['login']}" : "[#{user['login']}](#{user['html_url']})" end ENCAPSULATED_CHARACTERS = %w(< > * _ \( \) [ ] #) diff --git a/lib/github_changelog_generator/options.rb b/lib/github_changelog_generator/options.rb index b77503fa..f2582da9 100644 --- a/lib/github_changelog_generator/options.rb +++ b/lib/github_changelog_generator/options.rb @@ -28,6 +28,7 @@ class Options < SimpleDelegator config_file compare_link configure_sections + contributors_on_own_line date_format deprecated_labels deprecated_prefix diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 443fcc01..f4c1c9d3 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -81,7 +81,8 @@ def default_options security_prefix: "**Security fixes:**", http_cache: true, require: [], - config_file: ".github_changelog_generator" + config_file: ".github_changelog_generator", + contributors_on_own_line: false ) end end diff --git a/spec/unit/generator/entry_spec.rb b/spec/unit/generator/entry_spec.rb index d4e9f737..ff81ff4a 100644 --- a/spec/unit/generator/entry_spec.rb +++ b/spec/unit/generator/entry_spec.rb @@ -139,6 +139,107 @@ def default_sections end subject { described_class.new(options) } + + describe "contributors on own line" do + let(:options) do + Parser.default_options.merge( + user: "owner", + project: "repo", + breaking_labels: ["breaking"], + enhancement_labels: ["enhancement"], + bug_labels: ["bug"], + deprecated_labels: ["deprecated"], + removed_labels: ["removed"], + security_labels: ["security"], + verbose: false, + contributors_on_own_line: true + ) + end + + it "generates a header and body" do + changelog = <<-CHANGELOG.gsub(/^ {10}/, "") + ## [1.0.1](https://github.com/owner/repo/tree/1.0.1) (2017-12-04) + + [Full Changelog](https://github.com/owner/repo/compare/1.0.0...1.0.1) + + **Breaking changes:** + + - issue breaking [\\#8](https://github.com/owner/repo/issue/8) + - issue all the labels [\\#9](https://github.com/owner/repo/issue/9) + - issue all the labels different order [\\#10](https://github.com/owner/repo/issue/10) + - pr breaking [\\#23](https://github.com/owner/repo/pull/23) + + *[user5](https://github.com/user5)* + + - pr all the labels [\\#24](https://github.com/owner/repo/pull/24) + + *[user5](https://github.com/user5)* + + - pr all the labels different order [\\#25](https://github.com/owner/repo/pull/25) + + *[user5](https://github.com/user5)* + + **Implemented enhancements:** + + - issue enhancement [\\#6](https://github.com/owner/repo/issue/6) + - pr enhancement [\\#21](https://github.com/owner/repo/pull/21) + + *[user5](https://github.com/user5)* + + **Fixed bugs:** + + - issue bug [\\#7](https://github.com/owner/repo/issue/7) + - issue some unmapped labels [\\#11](https://github.com/owner/repo/issue/11) + - pr bug [\\#22](https://github.com/owner/repo/pull/22) + + *[user5](https://github.com/user5)* + + - pr some unmapped labels [\\#26](https://github.com/owner/repo/pull/26) + + *[user5](https://github.com/user5)* + + **Deprecated:** + + - issue deprecated [\\#13](https://github.com/owner/repo/issue/13) + - pr deprecated [\\#28](https://github.com/owner/repo/pull/28) + + *[user5](https://github.com/user5)* + + **Removed:** + + - issue removed [\\#14](https://github.com/owner/repo/issue/14) + - pr removed [\\#29](https://github.com/owner/repo/pull/29) + + *[user2](https://github.com/user2)* + + **Security fixes:** + + - issue security [\\#15](https://github.com/owner/repo/issue/15) + - pr security [\\#30](https://github.com/owner/repo/pull/30) + + *[user5](https://github.com/user5)* + + **Closed issues:** + + - issue no labels [\\#5](https://github.com/owner/repo/issue/5) + - issue no mapped labels [\\#12](https://github.com/owner/repo/issue/12) + + **Merged pull requests:** + + - pr no labels [\\#20](https://github.com/owner/repo/pull/20) + + *[user1](https://github.com/user1)* + + - pr no mapped labels [\\#27](https://github.com/owner/repo/pull/27) + + *[user5](https://github.com/user5)* + + CHANGELOG + + expect(subject.generate_entry_for_tag(pull_requests, issues, "1.0.1", "1.0.1", Time.new(2017, 12, 4, 12, 0, 0, "+00:00").utc, "1.0.0")).to eq(changelog) + end + end + describe "include issues without labels" do let(:options) do Parser.default_options.merge( pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy