Skip to content

Commit

Permalink
Remove --upgrade and --quiet flags from generated output files (#…
Browse files Browse the repository at this point in the history
…1873)

## Summary

Resolve #1814

I changed the behavior of `pip compile` to not display `--upgrade`
(`-U`) and `--quiet` (`-q`) for compatibility
  • Loading branch information
yasufumy committed Feb 23, 2024
1 parent 5a50a75 commit 0e2ea66
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion crates/uv/src/commands/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pub(crate) async fn pip_compile(
writeln!(
writer,
"{}",
format!("# {}", cmd(include_index_url, include_find_links)).green()
format!("# {}", cmd(include_index_url, include_find_links,)).green()
)?;
}

Expand Down Expand Up @@ -412,6 +412,7 @@ pub(crate) async fn pip_compile(
}

/// Format the `uv` command used to generate the output file.
#[allow(clippy::fn_params_excessive_bools)]
fn cmd(include_index_url: bool, include_find_links: bool) -> String {
let args = env::args_os()
.skip(1)
Expand Down Expand Up @@ -453,6 +454,24 @@ fn cmd(include_index_url: bool, include_find_links: bool) -> String {
}
}

// Always skip the `--upgrade` flag.
if arg == "--upgrade" || arg == "-U" {
*skip_next = None;
return Some(None);
}

// Always skip the `--quiet` flag.
if arg == "--quiet" || arg == "-q" {
*skip_next = None;
return Some(None);
}

// Always skip the `--verbose` flag.
if arg == "--verbose" || arg == "-v" {
*skip_next = None;
return Some(None);
}

// Return the argument.
Some(Some(arg))
})
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3045,7 +3045,7 @@ fn upgrade_all() -> Result<()> {
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --output-file requirements.txt --upgrade
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --output-file requirements.txt
black==23.10.1
click==8.1.7
# via black
Expand Down

0 comments on commit 0e2ea66

Please sign in to comment.