mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30: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,
|
force_update: bool,
|
||||||
validate_token: bool,
|
validate_token: bool,
|
||||||
) -> CargoResult<(Registry, SourceId)> {
|
) -> 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
|
// Parse all configuration options
|
||||||
let RegistryConfig {
|
let RegistryConfig {
|
||||||
token: token_config,
|
token: token_config,
|
||||||
|
@ -1247,3 +1247,19 @@ Caused by:
|
|||||||
.with_status(101)
|
.with_status(101)
|
||||||
.run();
|
.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…
x
Reference in New Issue
Block a user