From d802698d3e27a3cf091a56556df3562cc6ff996c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 9 May 2019 10:01:31 +0900 Subject: Push the current (topic) branch to the remote upstream --- tool/vcs.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tool/vcs.rb b/tool/vcs.rb index 8e6227685c..9310629089 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -510,6 +510,15 @@ class VCS dryrun = opts.fetch(:dryrun) {$DEBUG} if opts args = [COMMAND, "push"] args << "-n" if dryrun + (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] + upstream = cmd_read(%W"#{COMMAND} branch --list --format=%(upstream) #{ref}") + end + unless %r"\Arefs/remotes/([^/]+)/(.*)" =~ upstream + raise "Upstream not found" + end + args << $1 << "HEAD:#$2" STDERR.puts(args.inspect) if dryrun system(*args) or return false true -- cgit v1.2.3