2014-12-03 13:38:05 +00:00
|
|
|
module GitHubChangelogGenerator
|
|
|
|
class Generator
|
|
|
|
|
2014-12-03 14:31:43 +00:00
|
|
|
def initialize(options = nil)
|
2014-12-03 13:38:05 +00:00
|
|
|
@options = options
|
|
|
|
end
|
|
|
|
|
2015-02-25 17:02:41 +00:00
|
|
|
def get_string_for_issue(issue)
|
|
|
|
encapsulated_title = self.encapsulate_string issue[:title]
|
|
|
|
|
|
|
|
merge = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
|
|
|
|
unless issue.pull_request.nil?
|
|
|
|
if @options[:author]
|
|
|
|
if issue.user.nil?
|
|
|
|
merge += " ({Null user})\n\n"
|
|
|
|
else
|
|
|
|
merge += " ([#{issue.user.login}](#{issue.user.html_url}))\n\n"
|
|
|
|
end
|
2014-12-15 13:54:11 +00:00
|
|
|
end
|
2014-12-03 13:38:05 +00:00
|
|
|
end
|
2015-02-25 17:02:41 +00:00
|
|
|
merge += "\n"
|
2014-12-03 13:38:05 +00:00
|
|
|
end
|
|
|
|
|
2014-12-03 14:31:43 +00:00
|
|
|
def encapsulate_string(string)
|
|
|
|
|
|
|
|
string.gsub! '\\', '\\\\'
|
|
|
|
|
|
|
|
encpas_chars = %w(> * _ \( \) [ ])
|
2015-02-25 17:02:41 +00:00
|
|
|
encpas_chars.each { |char|
|
2014-12-03 14:31:43 +00:00
|
|
|
string.gsub! char, "\\#{char}"
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
end
|
|
|
|
|
2014-12-03 13:38:05 +00:00
|
|
|
end
|
2014-12-03 14:31:43 +00:00
|
|
|
|
2014-12-03 13:38:05 +00:00
|
|
|
end
|