From 8991bc9f62e43785afb2585380c83bd539e188e3 Mon Sep 17 00:00:00 2001 From: luciodaou <53634214+luciodaou@users.noreply.github.com> Date: Sat, 17 Feb 2024 00:45:57 -0300 Subject: [PATCH] feat(brew): adds "greedy-latest" option to Brew (#636) --- config.example.toml | 1 + src/config.rs | 10 ++++++++++ src/steps/os/unix.rs | 3 +++ 3 files changed, 14 insertions(+) diff --git a/config.example.toml b/config.example.toml index 0f988a2c..1b8a7932 100644 --- a/config.example.toml +++ b/config.example.toml @@ -104,6 +104,7 @@ [brew] # greedy_cask = true +# greedy_latest = true # autoremove = true # Upgrade formulae built from the HEAD branch; `brew upgrade --fetch-HEAD` diff --git a/src/config.rs b/src/config.rs index 259d5a91..b3c0ff76 100644 --- a/src/config.rs +++ b/src/config.rs @@ -254,6 +254,7 @@ pub struct Flatpak { #[serde(deny_unknown_fields)] pub struct Brew { greedy_cask: Option, + greedy_latest: Option, autoremove: Option, fetch_head: Option, } @@ -1089,6 +1090,15 @@ impl Config { .unwrap_or(false) } + /// Whether Brew cask should be greedy_latest + pub fn brew_greedy_latest(&self) -> bool { + self.config_file + .brew + .as_ref() + .and_then(|c| c.greedy_latest) + .unwrap_or(false) + } + /// Whether Brew should autoremove pub fn brew_autoremove(&self) -> bool { self.config_file diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index af3cf197..f14ec4e5 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -333,6 +333,9 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> if ctx.config().brew_cask_greedy() { brew_args.push("--greedy"); } + if ctx.config().brew_greedy_latest() { + brew_args.push("--greedy-latest"); + } } variant.execute(run_type).args(&brew_args).status_checked()?;