summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rwxr-xr-xtool/auto-style.rb16
-rw-r--r--tool/lib/envutil.rb16
2 files changed, 19 insertions, 13 deletions
diff --git a/tool/auto-style.rb b/tool/auto-style.rb
index 0c6ce6848a..71139c8eb8 100755
--- a/tool/auto-style.rb
+++ b/tool/auto-style.rb
@@ -15,8 +15,10 @@ class Git
@branch = branch
# GitHub may not fetch github.event.pull_request.base.sha at checkout
- git('fetch', '--depth=1', 'origin', @oldrev)
- git('fetch', '--depth=100', 'origin', @newrev)
+ git('log', '--format=%H', '-1', @oldrev, out: IO::NULL, err: [:child, :out]) or
+ git('fetch', '--depth=1', 'origin', @oldrev)
+ git('log', '--format=%H', '-1', "#@newrev~99", out: IO::NULL, err: [:child, :out]) or
+ git('fetch', '--depth=100', 'origin', @newrev)
with_clean_env do
@revs = {}
@@ -66,12 +68,14 @@ class Git
private
- def git(*args)
+ def git(*args, **opts)
cmd = ['git', *args].shelljoin
puts "+ #{cmd}"
- unless with_clean_env { system('git', *args) }
+ ret = with_clean_env { system('git', *args, **opts) }
+ unless ret or opts[:err]
abort "Failed to run: #{cmd}"
end
+ ret
end
def with_clean_env
@@ -233,8 +237,8 @@ edited_files = files.select do |f|
if File.fnmatch?("*.[ch]", f, File::FNM_PATHNAME) &&
!DIFFERENT_STYLE_FILES.any? {|pat| File.fnmatch?(pat, f, File::FNM_PATHNAME)}
- indent0 = true if src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n")
- indent0 = true if src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1')
+ indent0 = true if src.gsub!(/^\w+\([^\n]*?\)\K[ \t]*(?=\{( *\\)?$)/, '\1' "\n")
+ indent0 = true if src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b.*?( *\\)?$)/, '\2' "\n" '\1')
indent0 = true if src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '')
indent ||= indent0
end
diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb
index 573fd5122c..d02329d4f1 100644
--- a/tool/lib/envutil.rb
+++ b/tool/lib/envutil.rb
@@ -98,7 +98,7 @@ module EnvUtil
def start(pid, *args) end
def dump(pid, timeout: 60, reprieve: timeout&.div(4))
- dpid = start(pid, *command_file(File.join(__dir__, "dump.#{name}")))
+ dpid = start(pid, *command_file(File.join(__dir__, "dump.#{name}")), out: :err)
rescue Errno::ENOENT
return
else
@@ -121,8 +121,8 @@ module EnvUtil
register("gdb") do
class << self
def usable?; system(*%w[gdb --batch --quiet --nx -ex exit]); end
- def start(pid, *args)
- spawn(*%w[gdb --batch --quiet --pid #{pid}], *args)
+ def start(pid, *args, **opts)
+ spawn(*%W[gdb --batch --quiet --pid #{pid}], *args, **opts)
end
def command_file(file) "--command=#{file}"; end
end
@@ -131,8 +131,8 @@ module EnvUtil
register("lldb") do
class << self
def usable?; system(*%w[lldb -Q --no-lldbinit -o exit]); end
- def start(pid, *args)
- spawn(*%w[lldb --batch -Q --attach-pid #{pid}])
+ def start(pid, *args, **opts)
+ spawn(*%W[lldb --batch -Q --attach-pid #{pid}], *args, **opts)
end
def command_file(file) ["--source", file]; end
end
@@ -158,10 +158,12 @@ module EnvUtil
pgroup = pid
end
+ dumped = false
while signal = signals.shift
- if (dbg = Debugger.search) and [:ABRT, :KILL].include?(signal)
- dbg.dump(pid)
+ if !dumped and [:ABRT, :KILL].include?(signal)
+ Debugger.search&.dump(pid)
+ dumped = true
end
begin