improve script

This commit is contained in:
Petr Korolev 2014-12-03 16:31:43 +02:00
parent 68a8d8d2c8
commit 9aa156a02b
2 changed files with 19 additions and 9 deletions

View File

@ -314,10 +314,9 @@ module GitHubChangelogGenerator
intro = 'Implemented enhancement'
end
dict[:title].gsub! '>', '\>'
dict[:title].gsub! '*', '\*'
dict[:title].gsub! '_', '\_'
merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
enc_string = @generator.encapsulate_string dict[:title]
merge = "*#{intro}:* #{enc_string} [\\##{dict[:number]}](#{dict.html_url})\n\n"
log += "- #{merge}"
}
end

View File

@ -1,16 +1,14 @@
module GitHubChangelogGenerator
class Generator
def initialize(options)
def initialize(options = nil)
@options = options
end
def get_string_for_pull_request(pull_request)
pull_request[:title].gsub! '>', '\>'
pull_request[:title].gsub! '*', '\*'
pull_request[:title].gsub! '_', '\_'
encapsulated_title = self.encapsulate_string pull_request[:title]
merge = "#{@options[:merge_prefix]}#{pull_request[:title]} [\\##{pull_request[:number]}](#{pull_request.html_url})"
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
if @options[:author]
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
else
@ -19,5 +17,18 @@ module GitHubChangelogGenerator
merge
end
def encapsulate_string(string)
string.gsub! '\\', '\\\\'
encpas_chars = %w(> * _ \( \) [ ])
encpas_chars.each{ |char|
string.gsub! char, "\\#{char}"
}
string
end
end
end