diff --git a/config.example.toml b/config.example.toml index 72197327..0f988a2c 100644 --- a/config.example.toml +++ b/config.example.toml @@ -106,6 +106,9 @@ # greedy_cask = true # autoremove = true +# Upgrade formulae built from the HEAD branch; `brew upgrade --fetch-HEAD` +# fetch_head = true + [linux] # Arch Package Manager to use. diff --git a/src/config.rs b/src/config.rs index c7b62cd2..3b01e0e7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -254,6 +254,7 @@ pub struct Flatpak { pub struct Brew { greedy_cask: Option, autoremove: Option, + fetch_head: Option, } #[derive(Debug, Deserialize, Clone, Copy)] @@ -1096,6 +1097,15 @@ impl Config { .unwrap_or(false) } + /// Whether Brew should upgrade formulae built from the HEAD branch + pub fn brew_fetch_head(&self) -> bool { + self.config_file + .brew + .as_ref() + .and_then(|c| c.fetch_head) + .unwrap_or(false) + } + /// Whether Composer should update itself pub fn composer_self_update(&self) -> bool { self.config_file diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 5ef78637..af3cf197 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -285,10 +285,15 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result< let run_type = ctx.run_type(); variant.execute(run_type).arg("update").status_checked()?; - variant - .execute(run_type) - .args(["upgrade", "--formula"]) - .status_checked()?; + + let mut command = variant.execute(run_type); + command.args(["upgrade", "--formula"]); + + if ctx.config().brew_fetch_head() { + command.arg("--fetch-HEAD"); + } + + command.status_checked()?; if ctx.config().cleanup() { variant.execute(run_type).arg("cleanup").status_checked()?;