From 61ac6c83d2f7f4140681d1324db4627cd89d7bc9 Mon Sep 17 00:00:00 2001 From: Claude Becker Date: Thu, 30 Mar 2023 08:40:42 +0200 Subject: [PATCH 1/2] homebrew: respect greedy flag for cask upgrade_all --- .../6267-homebrew-cask-upgrade-all-greedy.yml | 2 ++ plugins/modules/homebrew_cask.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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 00000000000..610629cf13a --- /dev/null +++ b/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml @@ -0,0 +1,2 @@ +bugfixes: + - homebrew_cask - allows passing --greedy option to upgrade_all diff --git a/plugins/modules/homebrew_cask.py b/plugins/modules/homebrew_cask.py index 162c1846122..67f3caf7741 100644 --- a/plugins/modules/homebrew_cask.py +++ b/plugins/modules/homebrew_cask.py @@ -79,7 +79,8 @@ description: - Upgrade casks that auto update. - Passes --greedy to brew cask outdated when checking - if an installed cask has a newer version available. + if an installed cask has a newer version available, + or to brew cask upgrade when upgrading all casks. type: bool default: false ''' @@ -128,6 +129,11 @@ 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 @@ def _upgrade_all(self): else: cmd = [self.brew_path, 'cask', 'upgrade'] + if self.greedy: + cmd = cmd + ['--greedy'] + rc, out, err = '', '', '' if self.sudo_password: From c7114ce6deda77a567dc714b34d0048af249d54b Mon Sep 17 00:00:00 2001 From: Claude Becker Date: Thu, 30 Mar 2023 13:04:18 +0200 Subject: [PATCH 2/2] homebrew: implement feedback from code review --- .../fragments/6267-homebrew-cask-upgrade-all-greedy.yml | 4 ++-- plugins/modules/homebrew_cask.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml b/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml index 610629cf13a..c470cf3a7c6 100644 --- a/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml +++ b/changelogs/fragments/6267-homebrew-cask-upgrade-all-greedy.yml @@ -1,2 +1,2 @@ -bugfixes: - - homebrew_cask - allows passing --greedy option to upgrade_all +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 67f3caf7741..c992693b685 100644 --- a/plugins/modules/homebrew_cask.py +++ b/plugins/modules/homebrew_cask.py @@ -78,9 +78,9 @@ greedy: description: - Upgrade casks that auto update. - - Passes --greedy to brew cask outdated when checking + - Passes C(--greedy) to C(brew outdated --cask) when checking if an installed cask has a newer version available, - or to brew cask upgrade when upgrading all casks. + or to C(brew upgrade --cask) when upgrading all casks. type: bool default: false '''