1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Separate VCS::DEBUG_OUT

This commit is contained in:
Nobuyoshi Nakada 2019-09-04 23:54:41 +09:00
parent f6da4a5447
commit 9f59d30daa
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -7,6 +7,10 @@ require 'optparse'
ENV.delete('PWD') ENV.delete('PWD')
class VCS
DEBUG_OUT = STDERR.dup
end
unless File.respond_to? :realpath unless File.respond_to? :realpath
require 'pathname' require 'pathname'
def File.realpath(arg) def File.realpath(arg)
@ -15,7 +19,7 @@ unless File.respond_to? :realpath
end end
def IO.pread(*args) def IO.pread(*args)
STDERR.puts(args.inspect) if $DEBUG VCS::DEBUG_OUT.puts(args.inspect) if $DEBUG
popen(*args) {|f|f.read} popen(*args) {|f|f.read}
end end
@ -85,7 +89,7 @@ else
verbose, $VERBOSE = $VERBOSE, nil if RUBY_VERSION < "2.1" verbose, $VERBOSE = $VERBOSE, nil if RUBY_VERSION < "2.1"
refine IO.singleton_class do refine IO.singleton_class do
def popen(*args) def popen(*args)
STDERR.puts args.inspect if $DEBUG VCS::DEBUG_OUT.puts args.inspect if $DEBUG
super super
end end
end end
@ -95,7 +99,7 @@ else
using DebugPOpen using DebugPOpen
module DebugSystem module DebugSystem
def system(*args) def system(*args)
STDERR.puts args.inspect if $DEBUG VCS::DEBUG_OUT.puts args.inspect if $DEBUG
exception = false exception = false
opts = Hash.try_convert(args[-1]) opts = Hash.try_convert(args[-1])
if RUBY_VERSION >= "2.6" if RUBY_VERSION >= "2.6"
@ -417,7 +421,7 @@ class VCS
def commit def commit
args = %W"#{COMMAND} commit" args = %W"#{COMMAND} commit"
if dryrun? if dryrun?
STDERR.puts(args.inspect) VCS::DEBUG_OUT.puts(args.inspect)
return true return true
end end
system(*args) system(*args)
@ -434,7 +438,7 @@ class VCS
if srcdir and self.class.local_path?(srcdir) if srcdir and self.class.local_path?(srcdir)
opts[:chdir] ||= srcdir opts[:chdir] ||= srcdir
end end
STDERR.puts cmds.inspect if debug? VCS::DEBUG_OUT.puts cmds.inspect if debug?
cmds cmds
end end
@ -649,7 +653,7 @@ class VCS
branches = %W[refs/notes/commits:refs/notes/commits HEAD:#{branch}] branches = %W[refs/notes/commits:refs/notes/commits HEAD:#{branch}]
if dryrun? if dryrun?
branches.each do |b| branches.each do |b|
STDERR.puts((args + [b]).inspect) VCS::DEBUG_OUT.puts((args + [b]).inspect)
end end
return true return true
end end