summaryrefslogtreecommitdiff
path: root/tool/vcs.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-09 10:01:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-09 10:01:31 +0900
commitd802698d3e27a3cf091a56556df3562cc6ff996c (patch)
tree1d1488a1c9cbd121b2413d1641f4e6a5091ae0fc /tool/vcs.rb
parent4fabb744718ddbb2eb8f5f4a6ca3d47d8e770547 (diff)
Push the current (topic) branch to the remote upstream
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r--tool/vcs.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index 8e62276..9310629 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