mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 03:32:39 +00:00
Don't allow both --index and --registry to be specified at the same time.
Otherwise --index was being silently ignored.
This commit is contained in:
parent
9d00f9f07f
commit
2599071110
|
@ -369,6 +369,10 @@ fn registry(
|
|||
force_update: bool,
|
||||
validate_token: bool,
|
||||
) -> CargoResult<(Registry, SourceId)> {
|
||||
if index.is_some() && registry.is_some() {
|
||||
// Otherwise we would silently ignore one or the other.
|
||||
bail!("both `--index` and `--registry` should not be set at the same time");
|
||||
}
|
||||
// Parse all configuration options
|
||||
let RegistryConfig {
|
||||
token: token_config,
|
||||
|
|
|
@ -1247,3 +1247,19 @@ Caused by:
|
|||
.with_status(101)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn both_index_and_registry() {
|
||||
let p = project().file("src/lib.rs", "").build();
|
||||
for cmd in &["publish", "owner", "search", "yank --vers 1.0.0"] {
|
||||
p.cargo(cmd)
|
||||
.arg("--registry=foo")
|
||||
.arg("--index=foo")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"[ERROR] both `--index` and `--registry` \
|
||||
should not be set at the same time",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue