Merge pull request #392 from olleolleolle/feature/phase-usernames-as-github-logins

Carry PR #301: usernames_as_github_logins
This commit is contained in:
Petr Korolev 2016-07-04 11:10:47 +03:00 committed by GitHub
commit f09a6183a4
2 changed files with 18 additions and 10 deletions

View File

@ -160,7 +160,7 @@ module GitHubChangelogGenerator
# Parse issue and generate single line formatted issue line. # Parse issue and generate single line formatted issue line.
# #
# Example output: # Example output:
# - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) ([skywinder](https://github.com/skywinder)) # - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) (@skywinder)
# #
# @param [Hash] issue Fetched issue from GitHub # @param [Hash] issue Fetched issue from GitHub
# @return [String] Markdown-formatted single issue # @return [String] Markdown-formatted single issue
@ -168,17 +168,22 @@ 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})"
issue_line_with_user(title_with_number, issue)
end
unless issue.pull_request.nil? private
if @options[:author]
title_with_number += if issue.user.nil? def issue_line_with_user(line, issue)
" ({Null user})" return line if !@options[:author] || issue.pull_request.nil?
else
" ([#{issue.user.login}](#{issue.user.html_url}))" user = issue.user
end return "#{line} ({Null user})" unless user
end
if @options[:usernames_as_github_logins]
"#{line} (@#{user.login})"
else
"#{line} ([#{user.login}](#{user.html_url}))"
end end
title_with_number
end end
end end
end end

View File

@ -92,6 +92,9 @@ module GitHubChangelogGenerator
opts.on("--[no-]author", "Add author of pull-request in the end. Default is true") do |author| opts.on("--[no-]author", "Add author of pull-request in the end. Default is true") do |author|
options[:author] = author options[:author] = author
end end
opts.on("--usernames-as-github-logins", "Use GitHub tags instead of Markdown links for the author of an issue or pull-request.") do |v|
options[:usernames_as_github_logins] = v
end
opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v| opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v|
options[:unreleased_only] = v options[:unreleased_only] = v
end end