diff options
Diffstat (limited to 'tool')
-rw-r--r-- | tool/lib/vcs.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb index dd6162c8c2..2ecbfbed44 100644 --- a/tool/lib/vcs.rb +++ b/tool/lib/vcs.rb @@ -578,9 +578,7 @@ class VCS IO.copy_stream(r, path) end - def commit(opts = {}) - args = [COMMAND, "push"] - args << "-n" if dryrun + def upstream (branch = cmd_read(%W"#{COMMAND} symbolic-ref --short HEAD")).chomp! (upstream = cmd_read(%W"#{COMMAND} branch --list --format=%(upstream) #{branch}")).chomp! while ref = upstream[%r"\Arefs/heads/(.*)", 1] @@ -589,7 +587,14 @@ class VCS unless %r"\Arefs/remotes/([^/]+)/(.*)" =~ upstream raise "Upstream not found" end - args << $1 << "HEAD:#$2" + [$1, $2] + end + + def commit(opts = {}) + args = [COMMAND, "push"] + args << "-n" if dryrun + remote, branch = upstream + args << remote << "HEAD:#{branch}" if dryrun? STDERR.puts(args.inspect) return true |