delete --host command and message

This commit is contained in:
l00556901 2021-12-01 10:29:46 +08:00
parent 259ea8c055
commit 56b8ae7c44
7 changed files with 4 additions and 256 deletions

View File

@ -10,12 +10,6 @@ pub fn cli() -> App {
)
.arg(opt("quiet", "No output printed to stdout").short("q"))
.arg(Arg::with_name("token"))
// --host is deprecated (use --registry instead)
.arg(
opt("host", "Host to set the token for")
.value_name("HOST")
.hidden(true),
)
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
.after_help("Run `cargo help login` for more detailed information.\n")
}

View File

@ -32,7 +32,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
let ws = args.workspace(config)?;
let index = args.index(config)?;
let index = args.index()?;
ops::publish(
&ws,

View File

@ -23,7 +23,7 @@ pub fn cli() -> App {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
let index = args.index(config)?;
let index = args.index()?;
let limit = args.value_of_u32("limit")?;
let limit = min(100, limit.unwrap_or(10));
let query: Vec<&str> = args.values_of("query").unwrap_or_default().collect();

View File

@ -613,27 +613,8 @@ pub trait ArgMatchesExt {
}
}
fn index(&self, config: &Config) -> CargoResult<Option<String>> {
// TODO: deprecated. Remove once it has been decided `--host` can be removed
// We may instead want to repurpose the host flag, as mentioned in issue
// rust-lang/cargo#4208.
let msg = "The flag '--host' is no longer valid.
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.";
let index = match self._value_of("host") {
Some(host) => {
config.shell().warn(&msg)?;
Some(host.to_string())
}
None => self._value_of("index").map(|s| s.to_string()),
};
fn index(&self) -> CargoResult<Option<String>> {
let index = self._value_of("index").map(|s| s.to_string());
Ok(index)
}

View File

@ -66,83 +66,6 @@ fn check_token(expected_token: &str, registry: Option<&str>) -> bool {
}
}
#[cargo_test]
fn login_with_old_credentials() {
registry::init();
cargo_process("login --host")
.arg(registry_url().to_string())
.arg(TOKEN)
.run();
// Ensure that we get the new token for the registry
assert!(check_token(TOKEN, None));
}
#[cargo_test]
fn login_with_new_credentials() {
registry::init();
setup_new_credentials();
cargo_process("login --host")
.arg(registry_url().to_string())
.arg(TOKEN)
.run();
// Ensure that we get the new token for the registry
assert!(check_token(TOKEN, None));
}
#[cargo_test]
fn credentials_work_with_extension() {
registry::init();
setup_new_credentials_toml();
cargo_process("login --host")
.arg(registry_url().to_string())
.arg(TOKEN)
.run();
// Ensure that we get the new token for the registry
assert!(check_token(TOKEN, None));
}
#[cargo_test]
fn login_with_old_and_new_credentials() {
setup_new_credentials();
login_with_old_credentials();
}
#[cargo_test]
fn login_without_credentials() {
registry::init();
cargo_process("login --host")
.arg(registry_url().to_string())
.arg(TOKEN)
.run();
// Ensure that we get the new token for the registry
assert!(check_token(TOKEN, None));
}
#[cargo_test]
fn new_credentials_is_used_instead_old() {
registry::init();
setup_new_credentials();
cargo_process("login --host")
.arg(registry_url().to_string())
.arg(TOKEN)
.run();
let mut config = Config::new(Shell::new(), cargo_home(), cargo_home());
let _ = config.values();
let _ = config.load_credentials();
let token = config.get_string("registry.token").unwrap().map(|p| p.val);
assert_eq!(token.unwrap(), TOKEN);
}
#[cargo_test]
fn registry_credentials() {
registry::alt_init();

View File

@ -185,102 +185,6 @@ See [..]
validate_upload_foo();
}
// TODO: Deprecated
// remove once it has been decided --host can be removed
#[cargo_test]
fn simple_with_host() {
registry::init();
let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
license = "MIT"
description = "foo"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("publish --no-verify --token sekrit --host")
.arg(registry_url().to_string())
.with_stderr(&format!(
"\
[WARNING] The flag '--host' is no longer valid.
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] `{reg}` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
[UPLOADING] foo v0.0.1 ([CWD])
",
reg = registry_path().to_str().unwrap()
))
.run();
validate_upload_foo();
}
// TODO: Deprecated
// remove once it has been decided --host can be removed
#[cargo_test]
fn simple_with_index_and_host() {
registry::init();
let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
license = "MIT"
description = "foo"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("publish --no-verify --token sekrit --index")
.arg(registry_url().to_string())
.arg("--host")
.arg(registry_url().to_string())
.with_stderr(&format!(
"\
[WARNING] The flag '--host' is no longer valid.
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] `{reg}` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
[UPLOADING] foo v0.0.1 ([CWD])
",
reg = registry_path().to_str().unwrap()
))
.run();
validate_upload_foo();
}
#[cargo_test]
fn git_deps() {
registry::init();

View File

@ -181,60 +181,6 @@ fn simple() {
.run();
}
// TODO: Deprecated
// remove once it has been decided '--host' can be safely removed
#[cargo_test]
fn simple_with_host() {
setup();
cargo_process("search postgres --host")
.arg(registry_url().to_string())
.with_stderr(
"\
[WARNING] The flag '--host' is no longer valid.
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] `[CWD]/registry` index
",
)
.with_stdout_contains(SEARCH_RESULTS)
.run();
}
// TODO: Deprecated
// remove once it has been decided '--host' can be safely removed
#[cargo_test]
fn simple_with_index_and_host() {
setup();
cargo_process("search postgres --index")
.arg(registry_url().to_string())
.arg("--host")
.arg(registry_url().to_string())
.with_stderr(
"\
[WARNING] The flag '--host' is no longer valid.
Previous versions of Cargo accepted this flag, but it is being
deprecated. The flag is being renamed to 'index', as the flag
wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] `[CWD]/registry` index
",
)
.with_stdout_contains(SEARCH_RESULTS)
.run();
}
#[cargo_test]
fn multiple_query_params() {
setup();