mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-21 00:01:08 +00:00
[PR #11849/74c096b0 backport][stable-12] homebrew_cask: handle placeholder version from brew --version (#11855)
homebrew_cask: handle placeholder version from brew --version (#11849)
* homebrew_cask: handle placeholder version from brew --version
When brew is run as the wrong user, git repositories may be owned by
a different user, causing brew --version to output a placeholder like
"Homebrew >= 4.3.0 (shallow or no git repository)" instead of the real
version. The parsed version would then be lower than the 2.6.0 threshold,
causing _brew_cask_command_is_deprecated() to return False and the module
to use the disabled "brew cask" command syntax.
Detect the ">=" prefix in the parsed version and treat it as a modern
installation.
Fixes #4708
* homebrew_cask: add changelog fragment for #11849
---------
(cherry picked from commit 74c096b00c)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -440,14 +440,18 @@ class HomebrewCask:
|
||||
return self.brew_version
|
||||
|
||||
cmd = [self.brew_path, "--version"]
|
||||
|
||||
dummy, out, dummy = self.module.run_command(cmd, check_rc=True)
|
||||
|
||||
pattern = r"Homebrew (.*)(\d+\.\d+\.\d+)(-dirty)?"
|
||||
rematch = re.search(pattern, out)
|
||||
if not rematch:
|
||||
self.module.fail_json(msg="Failed to match regex to get brew version", stdout=out)
|
||||
self.brew_version = rematch.groups()[1]
|
||||
|
||||
prefix, version, dummy = rematch.groups()
|
||||
if ">=" in prefix:
|
||||
version = "99.0.0"
|
||||
|
||||
self.brew_version = version
|
||||
return self.brew_version
|
||||
|
||||
def _brew_cask_command_is_deprecated(self):
|
||||
|
||||
Reference in New Issue
Block a user