Remove `--upgrade` and `--quiet` flags from generated output files (#1873)

## Summary

Resolve #1814

I changed the behavior of `pip compile` to not display `--upgrade`
(`-U`) and `--quiet` (`-q`) for compatibility
This commit is contained in:
Taniguchi Yasufumi 2024-02-24 04:01:14 +09:00 committed by GitHub
parent 5a50a753bd
commit 0e2ea66b72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -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()
)?;
}
@ -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)
@ -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))
})

View File

@ -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