Extract username tagging

This commit is contained in:
phase 2015-10-25 11:12:16 -07:00 committed by Olle Jonsson
parent df31f98ce3
commit 4c737c9373

View File

@ -160,7 +160,7 @@ module GitHubChangelogGenerator
# Parse issue and generate single line formatted issue line.
#
# 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
# @return [String] Markdown-formatted single issue
@ -168,21 +168,22 @@ module GitHubChangelogGenerator
encapsulated_title = encapsulate_string issue[:title]
title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
unless issue.pull_request.nil?
if @options[:author]
if issue.user.nil?
title_with_number += " ({Null user})"
else
if issue.user.html_url.exclude? "github.com"
title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))"
else
title_with_number += " (@#{issue.user.login})"
end
end
end
issue_line_with_user(title_with_number, issue)
end
private
def issue_line_with_user(line, issue)
return line if !@options[:author] || issue.pull_request.nil?
user = issue.user
return "#{line} ({Null user})" unless user
if user.html_url.include?("github.com")
"#{line} (@#{user.login})"
else
"#{line} ([#{user.login}](#{user.html_url}))"
end
title_with_number
end
end
end