diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-10-30 12:39:43 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-10-30 17:06:33 +0900 |
commit | b64514f132615c00982d008bb2d7d2d1230d4f1c () | |
tree | 30b70f17c8c8c1b45ae37af7b162c0e7231b317c /tool/lib/vcs.rb | |
parent | 1acbcf0e58f60addf5aa7bb5e0ff7f6907a10fbc (diff) |
vcs.rb: prettify debug print
Notes: Merged: https://.com/ruby/ruby/pull/6647
-rw-r--r-- | tool/lib/vcs.rb | 37 |
1 files changed, 27 insertions, 10 deletions
@@ -1,6 +1,7 @@ # vcs require 'fileutils' require 'optparse' # This library is used by several other tools/ scripts to detect the current # VCS in use (e.g. SVN, Git) or to interact with that VCS. @@ -9,6 +10,22 @@ ENV.delete('PWD') class VCS DEBUG_OUT = STDERR.dup end unless File.respond_to? :realpath @@ -19,14 +36,14 @@ unless File.respond_to? :realpath end def IO.pread(*args) - VCS::DEBUG_OUT.puts(args.inspect) if $DEBUG popen(*args) {|f|f.read} end module DebugPOpen refine IO.singleton_class do def popen(*args) - VCS::DEBUG_OUT.puts args.inspect if $DEBUG super end end @@ -34,7 +51,7 @@ end using DebugPOpen module DebugSystem def system(*args) - VCS::DEBUG_OUT.puts args.inspect if $DEBUG exception = false opts = Hash.try_convert(args[-1]) if RUBY_VERSION >= "2.6" @@ -394,7 +411,7 @@ class VCS def commit args = %W"#{COMMAND} commit" if dryrun? - VCS::DEBUG_OUT.puts(args.inspect) return true end system(*args) @@ -411,7 +428,7 @@ class VCS if srcdir opts[:chdir] ||= srcdir end - VCS::DEBUG_OUT.puts cmds.inspect if debug? cmds end @@ -421,7 +438,7 @@ class VCS def cmd_read_at(srcdir, cmds) result = without_gitconfig { IO.pread(*cmd_args(cmds, srcdir)) } - VCS::DEBUG_OUT.puts result.inspect if debug? result end @@ -516,7 +533,7 @@ class VCS def initialize(*) super @srcdir = File.realpath(@srcdir) - VCS::DEBUG_OUT.puts @srcdir.inspect if debug? self end @@ -721,13 +738,13 @@ class VCS def commit(opts = {}) args = [COMMAND, "push"] - args << "-n" if dryrun remote, branch = upstream args << remote branches = %W[refs/notes/commits:refs/notes/commits HEAD:#{branch}] if dryrun? branches.each do |b| - VCS::DEBUG_OUT.puts((args + [b]).inspect) end return true end @@ -757,7 +774,7 @@ class VCS commits.each_with_index do |l, i| r, a, c = l.split(' ') dcommit = [COMMAND, "svn", "dcommit"] - dcommit.insert(-2, "-n") if dryrun dcommit << "--add-author-from" unless a == c dcommit << r system(*dcommit) or return false |