improve script

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

View File

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

View File

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