Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm new to Rust and I didn't come up with a good idea to avoid the clippy warning. I'd appreciate it if you suggest a better way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you have here is ok!Tthough I'm gonna remove the arguments because I think we should just always omit these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! Thank you for your comment.

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