summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-30 16:44:29 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-30 16:44:29 +0900
commit47144f91a176f263f870e05347d5b426efc40293 (patch)
tree4d0b6d7b0ff30aca47036cf9f2f5b885ee0dbfe9 /tool
parent2e6f777f9efa8ba15dcd1b7c1bb1917e5d31d6f8 (diff)
Separate VCS::GIT#upstream
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/vcs.rb13
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