More resilient brew formulae name handling (#9665)

* Remove update_homebrew=False (it's the default)

* Fix handling of irregular cases (brew does lowercase normalization)

* Fix handling of tap with no public fallback

* Add changelog fragment

* Add missing cleanup step

* Fix typo

* Check re-install and re-uninstall too
This commit is contained in:
Thibaut Decombe 2025-02-10 18:59:02 +01:00 committed by GitHub
parent 191a4d8f63
commit 75ffae43e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 125 additions and 29 deletions

View file

@ -385,9 +385,11 @@ class Homebrew(object):
self.outdated_packages.add(package_name)
def _extract_package_name(self, package_detail, is_cask):
canonical_name = package_detail["full_token"] if is_cask else package_detail["full_name"] # For ex: 'sqlite'
canonical_name = package_detail["full_token"] if is_cask else package_detail["full_name"] # For ex: 'sqlite', might contain a tap prefix.
name = package_detail["token"] if is_cask else package_detail["name"] # For ex: 'sqlite'
all_valid_names = set(package_detail.get("aliases", [])) # For ex: {'sqlite3'}
all_valid_names.add(canonical_name)
all_valid_names.update((canonical_name, name))
# Then make sure the user provided name resurface.
return (all_valid_names & set(self.packages)).pop()
@ -831,7 +833,7 @@ def main():
p = module.params
if p['name']:
packages = p['name']
packages = [package_name.lower() for package_name in p['name']]
else:
packages = None