From 1a873c6a70e49653d3735a48a4c8de13d29e972b Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 10 Feb 2018 06:42:35 +0000 Subject: [PATCH] vcs.rb: dryrun: option of GIT::SVN#commit git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/vcs.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tool/vcs.rb b/tool/vcs.rb index 77674c5c91..a4162ce190 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -491,16 +491,22 @@ class VCS end end - def commit + def last_changed_revision rev = cmd_read(%W"#{COMMAND} svn info"+[STDERR=>[:child, :out]])[/^Last Changed Rev: (\d+)/, 1] com = cmd_read(%W"#{COMMAND} svn find-rev r#{rev}").chomp + return rev, com + end + + def commit(opts = {}) + dryrun = opts.fetch(:dryrun) {$DEBUG} if opts + rev, com = last_changed_revision head = cmd_read(%W"#{COMMAND} symbolic-ref --short HEAD").chomp commits = cmd_read([COMMAND, "log", "--reverse", "--format=%H %ae %ce", "#{com}..@"], "rb").split("\n") commits.each_with_index do |l, i| r, a, c = l.split dcommit = [COMMAND, "svn", "dcommit"] - dcommit.insert(-2, "-n") if $DEBUG + dcommit.insert(-2, "-n") if dryrun dcommit << "--add-author-from" unless a == c dcommit << r system(*dcommit) or return false