feat: add fetch_head configuration option into brew (#679)

This commit is contained in:
Wallunen
2024-02-06 10:17:27 +02:00
committed by GitHub
parent 7007e76ab5
commit 77a8b3b7d2
3 changed files with 22 additions and 4 deletions

View File

@@ -106,6 +106,9 @@
# greedy_cask = true # greedy_cask = true
# autoremove = true # autoremove = true
# Upgrade formulae built from the HEAD branch; `brew upgrade --fetch-HEAD`
# fetch_head = true
[linux] [linux]
# Arch Package Manager to use. # Arch Package Manager to use.

View File

@@ -254,6 +254,7 @@ pub struct Flatpak {
pub struct Brew { pub struct Brew {
greedy_cask: Option<bool>, greedy_cask: Option<bool>,
autoremove: Option<bool>, autoremove: Option<bool>,
fetch_head: Option<bool>,
} }
#[derive(Debug, Deserialize, Clone, Copy)] #[derive(Debug, Deserialize, Clone, Copy)]
@@ -1096,6 +1097,15 @@ impl Config {
.unwrap_or(false) .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 /// Whether Composer should update itself
pub fn composer_self_update(&self) -> bool { pub fn composer_self_update(&self) -> bool {
self.config_file self.config_file

View File

@@ -285,10 +285,15 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
let run_type = ctx.run_type(); let run_type = ctx.run_type();
variant.execute(run_type).arg("update").status_checked()?; variant.execute(run_type).arg("update").status_checked()?;
variant
.execute(run_type) let mut command = variant.execute(run_type);
.args(["upgrade", "--formula"]) command.args(["upgrade", "--formula"]);
.status_checked()?;
if ctx.config().brew_fetch_head() {
command.arg("--fetch-HEAD");
}
command.status_checked()?;
if ctx.config().cleanup() { if ctx.config().cleanup() {
variant.execute(run_type).arg("cleanup").status_checked()?; variant.execute(run_type).arg("cleanup").status_checked()?;