Skip to content

Commit

Permalink
feat(pipx-update): add quiet flag for pipx upgrade-all on version 1.4…
Browse files Browse the repository at this point in the history
….0+ (#635)

This commit introduces conditional logic to the `run_pipx_update` function that checks the installed version of pipx. If the version is 1.4.0 or higher, the `--quiet` argument is added to the `pipx upgrade-all` command to suppress non-critical output during the upgrade process, adhering to the new feature introduced in pipx 1.4.0 as per the documentation (https://pipx.pypa.io/stable/docs/#pipx-upgrade-all). This change aims to make the upgrade process less verbose and more manageable in automated scripts or CI/CD pipelines where log brevity is beneficial.
  • Loading branch information
crrlcx authored Dec 31, 2023
1 parent 15f4ad7 commit ab35cd7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{fs, io::Write};
use color_eyre::eyre::eyre;
use color_eyre::eyre::Context;
use color_eyre::eyre::Result;
use semver::Version;
use tempfile::tempfile_in;
use tracing::{debug, error};

Expand Down Expand Up @@ -352,7 +353,20 @@ pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
let pipx = require("pipx")?;
print_separator("pipx");

ctx.run_type().execute(pipx).arg("upgrade-all").status_checked()
let mut command_args = vec!["upgrade-all"];

// pipx version 1.4.0 introduced a new command argument `pipx upgrade-all --quiet`
// (see https://pipx.pypa.io/stable/docs/#pipx-upgrade-all)
let version_str = Command::new("pipx")
.args(["--version"])
.output_checked_utf8()
.map(|s| s.stdout.trim().to_owned());
let version = Version::parse(&version_str?);
if matches!(version, Ok(version) if version >= Version::new(1, 4, 0)) {
command_args.push("--quiet")
}

ctx.run_type().execute(pipx).args(command_args).status_checked()
}

pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> {
Expand Down

0 comments on commit ab35cd7

Please sign in to comment.