From 923d3356460118105a64702dce5d3005a92192aa Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 07:09:19 +0200 Subject: [PATCH] [PR #6267/6c5c05df backport][stable-6] homebrew: respect greedy flag for cask upgrade_all (#6328) homebrew: respect greedy flag for cask upgrade_all (#6267) * homebrew: respect greedy flag for cask upgrade_all * homebrew: implement feedback from code review (cherry picked from commit 6c5c05dfdc8dbf1f3c785a26d2e4fd7d8f82bf7a) Co-authored-by: Claude Becker --- .../6267-homebrew-cask-upgrade-all-greedy.yml | 2 ++ plugins/modules/homebrew_cask.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml diff --git a/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml b/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml new file mode 100644 index 0000000000..c470cf3a7c --- /dev/null +++ b/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml @@ -0,0 +1,2 @@ +minor_changes: + - homebrew_cask - allows passing ``--greedy`` option to ``upgrade_all`` (https://github.com/ansible-collections/community.general/pull/6267). diff --git a/plugins/modules/homebrew_cask.py b/plugins/modules/homebrew_cask.py index 162c184612..c992693b68 100644 --- a/plugins/modules/homebrew_cask.py +++ b/plugins/modules/homebrew_cask.py @@ -78,8 +78,9 @@ options: greedy: description: - Upgrade casks that auto update. - - Passes --greedy to brew cask outdated when checking - if an installed cask has a newer version available. + - Passes C(--greedy) to C(brew outdated --cask) when checking + if an installed cask has a newer version available, + or to C(brew upgrade --cask) when upgrading all casks. type: bool default: false ''' @@ -128,6 +129,11 @@ EXAMPLES = ''' community.general.homebrew_cask: upgrade_all: true +- name: Upgrade all casks with greedy option + community.general.homebrew_cask: + upgrade_all: true + greedy: true + - name: Upgrade given cask with force option community.general.homebrew_cask: name: alfred @@ -581,6 +587,9 @@ class HomebrewCask(object): else: cmd = [self.brew_path, 'cask', 'upgrade'] + if self.greedy: + cmd = cmd + ['--greedy'] + rc, out, err = '', '', '' if self.sudo_password: