1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-21 03:09:04 +00:00

homebrew_cask: fix false failure on upgrade of latest-versioned casks (#11838)

* homebrew_cask: fix false failure on upgrade of latest-versioned casks

Use rc == 0 to determine upgrade success, consistent with _upgrade_all().
The previous check (_current_cask_is_installed() and not _current_cask_is_outdated())
was unreliable: for `latest`-versioned casks under --greedy, brew may still
list the cask as outdated after a successful upgrade, causing the task to fail
with a harmless warning from stderr as the error message.

Fixes #1647

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* homebrew_cask: add changelog fragment for #11838

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix changelog fragment

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky 2026-04-19 22:28:06 +12:00 committed by GitHub
parent 6c809dd9db
commit d0d213a41d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,6 @@
bugfixes:
- homebrew_cask - fix false task failure when upgrading casks with ``version=latest``;
the post-upgrade check incorrectly re-ran ``brew outdated`` (which always lists ``latest``
casks as outdated under ``--greedy``), now uses the command exit code instead
(https://github.com/ansible-collections/community.general/issues/1647,
https://github.com/ansible-collections/community.general/pull/11838).

View file

@ -656,7 +656,7 @@ class HomebrewCask:
else:
rc, out, err = self.module.run_command(cmd)
if self._current_cask_is_installed() and not self._current_cask_is_outdated():
if rc == 0:
self.changed_count += 1
self.changed = True
self.message = f"Cask upgraded: {self.current_cask}"