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

Error when multiple git references are provided in uv add #5502

Merged
merged 1 commit into from
Jul 30, 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
6 changes: 3 additions & 3 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2054,15 +2054,15 @@ pub struct AddArgs {
pub raw_sources: bool,

/// Specific commit to use when adding from Git.
#[arg(long)]
#[arg(long, group = "git-ref", action = clap::ArgAction::Set)]
pub rev: Option<String>,

/// Tag to use when adding from git.
#[arg(long)]
#[arg(long, group = "git-ref", action = clap::ArgAction::Set)]
pub tag: Option<String>,

/// Branch to use when adding from git.
#[arg(long)]
#[arg(long, group = "git-ref", action = clap::ArgAction::Set)]
pub branch: Option<String>,

/// Extras to activate for the dependency; may be provided more than once.
Expand Down
68 changes: 68 additions & 0 deletions crates/uv/tests/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2033,3 +2033,71 @@ fn add_frozen() -> Result<()> {

Ok(())
}

#[test]
fn add_reject_multiple_git_ref_flags() {
let context = TestContext::new("3.12");

// --tag and --branch
uv_snapshot!(context
.add(&[])
.arg("foo")
.arg("--tag")
.arg("0.0.1")
.arg("--branch")
.arg("test"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--tag <TAG>' cannot be used with '--branch <BRANCH>'

Usage: uv add --cache-dir [CACHE_DIR] --tag <TAG> --exclude-newer <EXCLUDE_NEWER> <REQUIREMENTS>...

For more information, try '--help'.
"###
);

// --tag and --rev
uv_snapshot!(context
.add(&[])
.arg("foo")
.arg("--tag")
.arg("0.0.1")
.arg("--rev")
.arg("326b943"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--tag <TAG>' cannot be used with '--rev <REV>'

Usage: uv add --cache-dir [CACHE_DIR] --tag <TAG> --exclude-newer <EXCLUDE_NEWER> <REQUIREMENTS>...

For more information, try '--help'.
"###
);

// --tag and --tag
uv_snapshot!(context
.add(&[])
.arg("foo")
.arg("--tag")
.arg("0.0.1")
.arg("--tag")
.arg("0.0.2"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--tag <TAG>' cannot be used multiple times

Usage: uv add [OPTIONS] <REQUIREMENTS>...

For more information, try '--help'.
"###
);
}
Loading