diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-30 16:44:29 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-30 16:44:29 +0900 |
commit | 47144f91a176f263f870e05347d5b426efc40293 (patch) | |
tree | 4d0b6d7b0ff30aca47036cf9f2f5b885ee0dbfe9 /tool | |
parent | 2e6f777f9efa8ba15dcd1b7c1bb1917e5d31d6f8 (diff) | |
download | ruby-47144f91a176f263f870e05347d5b426efc40293.tar.gz |
Separate VCS::GIT#upstream
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 |