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

pip compile: change order of check to handle exact argument first #5111

Merged
merged 1 commit into from
Jul 16, 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
27 changes: 14 additions & 13 deletions crates/uv/src/commands/pip/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,16 @@ fn cmd(

// Skip any `--find-links` URLs, unless requested.
if !include_find_links {
if arg.starts_with("--find-links=") || arg.starts_with("-f") {
// Reset state; skip this iteration.
*skip_next = None;
// Always skip the `--find-links` and mark the next item to be skipped
if arg == "--find-links" || arg == "-f" {
*skip_next = Some(true);
return Some(None);
}

// Mark the next item as (to be) skipped.
if arg == "--find-links" || arg == "-f" {
*skip_next = Some(true);
// Skip only this argument if option and value are together
if arg.starts_with("--find-links=") || arg.starts_with("-f") {
// Reset state; skip this iteration.
*skip_next = None;
return Some(None);
}
}
Expand All @@ -547,16 +548,16 @@ fn cmd(
return Some(None);
}

// Always skip the `--upgrade-package` flag
if arg.starts_with("--upgrade-package=") || arg.starts_with("-P") {
// Reset state; skip this iteration.
*skip_next = None;
// Always skip the `--upgrade-package` and mark the next item to be skipped
if arg == "--upgrade-package" || arg == "-P" {
*skip_next = Some(true);
return Some(None);
}

// Mark the next item as (to be) skipped.
if arg == "--upgrade-package" || arg == "-P" {
*skip_next = Some(true);
// Skip only this argument if option and value are together
if arg.starts_with("--upgrade-package=") || arg.starts_with("-P") {
// Reset state; skip this iteration.
*skip_next = None;
return Some(None);
}

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 @@ -4807,7 +4807,7 @@ fn upgrade_constraint() -> Result<()> {
.arg("requirements.in")
.arg("--output-file")
.arg("requirements.txt")
.arg("--upgrade-package")
.arg("-P")
.arg("iniconfig"), @r###"
success: true
exit_code: 0
Expand Down
Loading