Skip to content

Commit 4b9373f

Browse files
brad2014felixfonteinrussoz
authored
Homebrew: Emit a useful error message if brew info reports a package tap is null. (#10013)
* Fix #10012. Homebrew: Emit a useful error message if a package tap is null. This can happen if an installed package is subsequently removed from the tap (e.g. it is withdrawn by homebrew). * Added changelogs fragment for PR 10013 * Do not raise error when tap is null in package_detail pylint: remove trailing whitespace * Minor: Update plugins/modules/homebrew.py Co-authored-by: Felix Fontein <[email protected]> * Minor: Update changelogs/fragments/10012-improve-error-handling-homebrew-missing-tap.yml Co-authored-by: Alexei Znamensky <[email protected]> * Update plugins/modules/homebrew.py Co-authored-by: Felix Fontein <[email protected]> --------- Co-authored-by: Felix Fontein <[email protected]> Co-authored-by: Alexei Znamensky <[email protected]>
1 parent ce421db commit 4b9373f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- homebrew - emit a useful error message if ``brew info`` reports a package tap is ``null`` (https://github.com/ansible-collections/community.general/pull/10013, https://github.com/ansible-collections/community.general/issues/10012).

plugins/modules/homebrew.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,15 @@ def _extract_package_name(self, package_detail, is_cask):
399399
name = package_detail["name"]
400400
full_name = package_detail["full_name"]
401401

402-
tapped_name = package_detail["tap"] + "/" + name
402+
# Issue https://github.com/ansible-collections/community.general/issues/9803:
403+
# name can include the tap as a prefix, in order to disambiguate,
404+
# e.g. casks from identically named formulae.
405+
#
406+
# Issue https://github.com/ansible-collections/community.general/issues/10012:
407+
# package_detail["tap"] is None if package is no longer available.
408+
tapped_name = [package_detail["tap"] + "/" + name] if package_detail["tap"] else []
403409
aliases = package_detail.get("aliases", [])
404-
405-
package_names = set([name, full_name, tapped_name] + aliases)
410+
package_names = set([name, full_name] + tapped_name + aliases)
406411

407412
# Finally, identify which of all those package names was the one supplied by the user.
408413
package_names = package_names & set(self.packages)

0 commit comments

Comments
 (0)