Merge pull request #15150 from muzimuzhi/tap-formula-file

Tighten `tap.formula_file?(file)` and `tap.formula_files` to not detect cask file as formula
This commit is contained in:
Mike McQuaid 2023-04-06 08:37:50 +01:00 committed by GitHub
commit 104434c1d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -498,7 +498,7 @@ class Tap
formula_dir.find
else
formula_dir.children
end.select(&method(:ruby_file?))
end.select(&method(:formula_file?))
else
[]
end
@ -561,7 +561,7 @@ class Tap
file.extname == ".rb"
end
# return true if given path would present a {Formula} file in this {Tap}.
# returns true if given path would present a {Formula} file in this {Tap}.
# accepts both absolute path and relative path (relative to this {Tap}'s path)
# @private
sig { params(file: T.any(String, Pathname)).returns(T::Boolean) }
@ -569,11 +569,12 @@ class Tap
file = Pathname.new(file) unless file.is_a? Pathname
file = file.expand_path(path)
return false unless ruby_file?(file)
return false if cask_file?(file)
file.to_s.start_with?("#{formula_dir}/")
end
# return true if given path would present a {Cask} file in this {Tap}.
# returns true if given path would present a {Cask} file in this {Tap}.
# accepts both absolute path and relative path (relative to this {Tap}'s path)
# @private
sig { params(file: T.any(String, Pathname)).returns(T::Boolean) }