summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-06-17 00:46:16 +0900
committerNobuyoshi Nakada <[email protected]>2025-06-17 12:30:18 +0900
commitc09619d91163ea7c042ee3b5de20c23eaf5a2aba ()
treec625865d65ac67bb5ad4b0ebe677df3fd5588328 /tool
parent21c7131df818c1f7f571d4ccf9be150d2c9cc374 (diff)
Auto-style indent
Notes: Merged: https://.com/ruby/ruby/pull/13634
-rwxr-xr-x[-rw-r--r--]tool/auto-style.rb19
1 files changed, 17 insertions, 2 deletions
@@ -173,6 +173,10 @@ IGNORED_FILES = [
%r{\Asample/trick[^/]*/},
]
oldrev, newrev, pushref = ARGV
unless dry_run = pushref.empty?
branch = IO.popen(['git', 'rev-parse', '--symbolic', '--abbrev-ref', pushref], &:read).strip
@@ -194,7 +198,7 @@ if files.empty?
exit
end
-trailing = eofnewline = expandtab = false
edited_files = files.select do |f|
src = File.binread(f) rescue next
@@ -202,6 +206,8 @@ edited_files = files.select do |f|
trailing0 = false
expandtab0 = false
src.gsub!(/^.*$/).with_index do |line, lineno|
trailing = trailing0 = true if line.sub!(/[ \t]+$/, '')
line
@@ -225,7 +231,15 @@ edited_files = files.select do |f|
end
end
- if trailing0 or eofnewline0 or expandtab0
File.binwrite(f, src)
true
end
@@ -236,6 +250,7 @@ else
msg = [('remove trailing spaces' if trailing),
('append newline at EOF' if eofnewline),
('expand tabs' if expandtab),
].compact
message = "* #{msg.join(', ')}. [ci skip]"
if expandtab