Merge pull request #16069 from apainintheneck/handle-name-conflicts-in-to_paths
cli/named_args: better handle name conflicts in #to_paths
This commit is contained in:
commit
d2f07f884d
@ -221,6 +221,10 @@ module Homebrew
|
|||||||
to_formulae_to_casks(only: only, method: :resolve)
|
to_formulae_to_casks(only: only, method: :resolve)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
LOCAL_PATH_REGEX = %r{^/|[.]|/$}.freeze
|
||||||
|
TAP_NAME_REGEX = %r{^[^./]+/[^./]+$}.freeze
|
||||||
|
private_constant :LOCAL_PATH_REGEX, :TAP_NAME_REGEX
|
||||||
|
|
||||||
# Keep existing paths and try to convert others to tap, formula or cask paths.
|
# Keep existing paths and try to convert others to tap, formula or cask paths.
|
||||||
# If a cask and formula with the same name exist, includes both their paths
|
# If a cask and formula with the same name exist, includes both their paths
|
||||||
# unless `only` is specified.
|
# unless `only` is specified.
|
||||||
@ -230,9 +234,9 @@ module Homebrew
|
|||||||
@to_paths[only] ||= Homebrew.with_no_api_env_if_needed(@without_api) do
|
@to_paths[only] ||= Homebrew.with_no_api_env_if_needed(@without_api) do
|
||||||
downcased_unique_named.flat_map do |name|
|
downcased_unique_named.flat_map do |name|
|
||||||
path = Pathname(name).expand_path
|
path = Pathname(name).expand_path
|
||||||
if only.nil? && File.exist?(name)
|
if only.nil? && name.match?(LOCAL_PATH_REGEX) && path.exist?
|
||||||
path
|
path
|
||||||
elsif name.count("/") == 1 && !name.start_with?("./", "/")
|
elsif name.match?(TAP_NAME_REGEX)
|
||||||
tap = Tap.fetch(name)
|
tap = Tap.fetch(name)
|
||||||
|
|
||||||
if recurse_tap
|
if recurse_tap
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user