Simplify expand_tabs.rb file selection
This commit is contained in:
parent
a5b809e994
commit
1c5a268239
@ -139,10 +139,8 @@ git = Git.new('HEAD^', 'HEAD')
|
|||||||
|
|
||||||
Dir.chdir(git.toplevel) do
|
Dir.chdir(git.toplevel) do
|
||||||
paths = git.updated_paths
|
paths = git.updated_paths
|
||||||
paths.select! {|l|
|
paths.select! {|f|
|
||||||
/^\d/ !~ l and /\.bat\z/ !~ l and
|
(f.end_with?('.c') || f.end_with?('.h') || f == 'insns.def') && EXPANDTAB_IGNORED_FILES.all? { |re| !f.match(re) }
|
||||||
(/\A(?:config|[Mm]akefile|GNUmakefile|README)/ =~ File.basename(l) or
|
|
||||||
/\A\z|\.(?:[chsy]|\d+|e?rb|tmpl|bas[eh]|z?sh|in|ma?k|def|src|trans|rdoc|ja|en|el|sed|awk|p[ly]|scm|mspec|html|)\z/ =~ File.extname(l))
|
|
||||||
}
|
}
|
||||||
files = paths.select {|n| File.file?(n)}
|
files = paths.select {|n| File.file?(n)}
|
||||||
exit if files.empty?
|
exit if files.empty?
|
||||||
@ -152,7 +150,7 @@ Dir.chdir(git.toplevel) do
|
|||||||
|
|
||||||
expanded = false
|
expanded = false
|
||||||
updated_lines = git.updated_lines(f)
|
updated_lines = git.updated_lines(f)
|
||||||
if !updated_lines.empty? && (f.end_with?('.c') || f.end_with?('.h') || f == 'insns.def') && EXPANDTAB_IGNORED_FILES.all? { |re| !f.match(re) }
|
unless updated_lines.empty?
|
||||||
src.gsub!(/^.*$/).with_index do |line, lineno|
|
src.gsub!(/^.*$/).with_index do |line, lineno|
|
||||||
if updated_lines.include?(lineno) && line.start_with?("\t") # last-committed line with hard tabs
|
if updated_lines.include?(lineno) && line.start_with?("\t") # last-committed line with hard tabs
|
||||||
expanded = true
|
expanded = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user