mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
style: better handle HOMEBREW_REPOSITORY.
If you do `brew style --fix .` in `HOMEBREW_REPOSITORY` it behaves very weirdly and uses the incorrect rules. If this is passed, assume that people want the same behaviour as `brew style --fix`. While we're here, do some argument naming and code cleanup.
This commit is contained in:
parent
5cea834e82
commit
bc687314af
@ -42,7 +42,7 @@ module Homebrew
|
|||||||
display_cop_names: false,
|
display_cop_names: false,
|
||||||
reset_cache: false,
|
reset_cache: false,
|
||||||
debug: false, verbose: false)
|
debug: false, verbose: false)
|
||||||
raise ArgumentError, "Invalid output type: #{output_type.inspect}" unless [:print, :json].include?(output_type)
|
raise ArgumentError, "Invalid output type: #{output_type.inspect}" if [:print, :json].exclude?(output_type)
|
||||||
|
|
||||||
shell_files, ruby_files =
|
shell_files, ruby_files =
|
||||||
Array(files).map(&method(:Pathname))
|
Array(files).map(&method(:Pathname))
|
||||||
@ -97,7 +97,7 @@ module Homebrew
|
|||||||
--force-exclusion
|
--force-exclusion
|
||||||
]
|
]
|
||||||
args << if fix
|
args << if fix
|
||||||
"-A"
|
"--auto-correct-all"
|
||||||
else
|
else
|
||||||
"--parallel"
|
"--parallel"
|
||||||
end
|
end
|
||||||
@ -125,12 +125,11 @@ module Homebrew
|
|||||||
args << "--only" << cops_to_include.join(",")
|
args << "--only" << cops_to_include.join(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
has_non_formula = files.any? do |file|
|
files&.map!(&:expand_path)
|
||||||
File.expand_path(file).start_with? HOMEBREW_LIBRARY_PATH
|
if files.blank? || files == [HOMEBREW_REPOSITORY]
|
||||||
end
|
files = [HOMEBREW_LIBRARY_PATH]
|
||||||
|
elsif files.none? { |f| f.to_s.start_with? HOMEBREW_LIBRARY_PATH }
|
||||||
if files.any? && !has_non_formula
|
config = if files.any? { |f| (f/"spec").exist? }
|
||||||
config = if files.first && File.exist?("#{files.first}/spec")
|
|
||||||
HOMEBREW_LIBRARY/".rubocop_rspec.yml"
|
HOMEBREW_LIBRARY/".rubocop_rspec.yml"
|
||||||
else
|
else
|
||||||
HOMEBREW_LIBRARY/".rubocop.yml"
|
HOMEBREW_LIBRARY/".rubocop.yml"
|
||||||
@ -138,11 +137,7 @@ module Homebrew
|
|||||||
args << "--config" << config
|
args << "--config" << config
|
||||||
end
|
end
|
||||||
|
|
||||||
if files.blank?
|
args += files
|
||||||
args << HOMEBREW_LIBRARY_PATH
|
|
||||||
else
|
|
||||||
args += files
|
|
||||||
end
|
|
||||||
|
|
||||||
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
|
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user