diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2019-04-28 19:33:41 +0900 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2019-04-28 20:17:20 +0900 |
commit | 4d8ad48f7dc610f58150daf92a859ed53fdd3a6c (patch) | |
tree | 020ef243e3f8edaefb1dfd4cd892b5a2bd217b30 /tool | |
parent | 5d24fba544352a32fdd4e06fa25dc0625c6860f1 (diff) | |
download | ruby-4d8ad48f7dc610f58150daf92a859ed53fdd3a6c.tar.gz |
Support git as redmine-backporter's done destination
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/redmine-backporter.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tool/redmine-backporter.rb b/tool/redmine-backporter.rb index eef8bbb3ca..3c2d46d4ea 100755 --- a/tool/redmine-backporter.rb +++ b/tool/redmine-backporter.rb @@ -9,6 +9,7 @@ require 'strscan' require 'optparse' require 'abbrev' require 'pp' +require 'shellwords' begin require 'readline' rescue LoadError @@ -239,6 +240,10 @@ def find_svn_log(pattern) `svn log --xml --stop-on-copy --search="#{pattern}" #{RUBY_REPO_PATH}` end +def find_git_log(pattern) + `git #{RUBY_REPO_PATH ? "-C #{RUBY_REPO_PATH.shellecape}" : ""} log --grep="#{pattern}"` +end + def show_last_journal(http, uri) res = http.get("#{uri.path}?include=journals") res.value @@ -431,11 +436,19 @@ eom next end - log = find_svn_log("##@issue]") - if log && /revision="(?<rev>\d+)/ =~ log + if system("svn info #{RUBY_REPO_PATH&.shellescape} > /dev/null 2>&1") # SVN + if log = find_svn_log("##@issue]") && /revision="(?<rev>\d+)/ =~ log + rev = "r#{rev}" + end + else # Git + if log = find_git_log("##@issue]") + /^commit (?<rev>\h{40})$/ =~ log + end + end + if log && rev str = log[/merge revision\(s\) ([^:]+)(?=:)/] str.insert(5, "d") - str = "ruby_#{TARGET_VERSION.tr('.','_')} r#{rev} #{str}." + str = "ruby_#{TARGET_VERSION.tr('.','_')} #{rev} #{str}." if notes str << "\n" str << notes |