Skip when the resource name is the same as the formula name

- Otherwise we get an audit failure in, for example, the `twine-pypi`
  formula for the package name from its `url` that's actually `twine`.
- For this we only should track `resource "name"` blocks.
This commit is contained in:
Issy Long 2023-09-06 23:29:06 +01:00
parent bb44d66e79
commit 08f58ab5f7
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -102,6 +102,7 @@ module Homebrew
def audit_resource_name_matches_pypi_package_name_in_url
return unless url.match?(%r{^https?://files\.pythonhosted\.org/packages/})
return if name == owner.name # Skip the top-level package name as we only care about `resource "foo"` blocks.
pypi_package_name = url.split("/").last.split(/[-.]\d+?./).first.gsub(/[_.]/, "-")
return if name.casecmp(pypi_package_name).zero?