Skip to content

Commit c87b986

Browse files
committed
Auto merge of #10145 - QiangHeisenberg:deprecated, r=alexcrichton
delete --host command and message close #10121 The warning for this command has been around for a long time, and it seems safe to delete it now. According to Alex's words in the issue, I think he supports deletion. I'm sorry if I misunderstood it and feel free to close it.
2 parents 0bbfc5e + cf621fd commit c87b986

File tree

7 files changed

+7
-240
lines changed

7 files changed

+7
-240
lines changed

src/bin/cargo/commands/login.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ pub fn cli() -> App {
1010
)
1111
.arg_quiet()
1212
.arg(Arg::with_name("token"))
13-
// --host is deprecated (use --registry instead)
14-
.arg(
15-
opt("host", "Host to set the token for")
16-
.value_name("HOST")
17-
.hidden(true),
18-
)
1913
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
2014
.after_help("Run `cargo help login` for more detailed information.\n")
2115
}

src/bin/cargo/commands/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
3232

3333
let registry = args.registry(config)?;
3434
let ws = args.workspace(config)?;
35-
let index = args.index(config)?;
35+
let index = args.index()?;
3636

3737
ops::publish(
3838
&ws,

src/bin/cargo/commands/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn cli() -> App {
2323

2424
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
2525
let registry = args.registry(config)?;
26-
let index = args.index(config)?;
26+
let index = args.index()?;
2727
let limit = args.value_of_u32("limit")?;
2828
let limit = min(100, limit.unwrap_or(10));
2929
let query: Vec<&str> = args.values_of("query").unwrap_or_default().collect();

src/cargo/util/command_prelude.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -620,27 +620,8 @@ pub trait ArgMatchesExt {
620620
}
621621
}
622622

623-
fn index(&self, config: &Config) -> CargoResult<Option<String>> {
624-
// TODO: deprecated. Remove once it has been decided `--host` can be removed
625-
// We may instead want to repurpose the host flag, as mentioned in issue
626-
// rust-lang/cargo#4208.
627-
let msg = "The flag '--host' is no longer valid.
628-
629-
Previous versions of Cargo accepted this flag, but it is being
630-
deprecated. The flag is being renamed to 'index', as the flag
631-
wants the location of the index. Please use '--index' instead.
632-
633-
This will soon become a hard error, so it's either recommended
634-
to update to a fixed version or contact the upstream maintainer
635-
about this warning.";
636-
637-
let index = match self._value_of("host") {
638-
Some(host) => {
639-
config.shell().warn(&msg)?;
640-
Some(host.to_string())
641-
}
642-
None => self._value_of("index").map(|s| s.to_string()),
643-
};
623+
fn index(&self) -> CargoResult<Option<String>> {
624+
let index = self._value_of("index").map(|s| s.to_string());
644625
Ok(index)
645626
}
646627

tests/testsuite/login.rs

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Tests for the `cargo login` command.
22
3-
use cargo::core::Shell;
4-
use cargo::util::config::Config;
53
use cargo_test_support::install::cargo_home;
6-
use cargo_test_support::registry::{self, registry_url};
4+
use cargo_test_support::registry;
75
use cargo_test_support::{cargo_process, paths, t};
86
use std::fs::{self, OpenOptions};
97
use std::io::prelude::*;
@@ -18,11 +16,6 @@ fn setup_new_credentials() {
1816
setup_new_credentials_at(config);
1917
}
2018

21-
fn setup_new_credentials_toml() {
22-
let config = cargo_home().join("credentials.toml");
23-
setup_new_credentials_at(config);
24-
}
25-
2619
fn setup_new_credentials_at(config: PathBuf) {
2720
t!(fs::create_dir_all(config.parent().unwrap()));
2821
t!(fs::write(
@@ -66,83 +59,6 @@ fn check_token(expected_token: &str, registry: Option<&str>) -> bool {
6659
}
6760
}
6861

69-
#[cargo_test]
70-
fn login_with_old_credentials() {
71-
registry::init();
72-
73-
cargo_process("login --host")
74-
.arg(registry_url().to_string())
75-
.arg(TOKEN)
76-
.run();
77-
78-
// Ensure that we get the new token for the registry
79-
assert!(check_token(TOKEN, None));
80-
}
81-
82-
#[cargo_test]
83-
fn login_with_new_credentials() {
84-
registry::init();
85-
setup_new_credentials();
86-
87-
cargo_process("login --host")
88-
.arg(registry_url().to_string())
89-
.arg(TOKEN)
90-
.run();
91-
92-
// Ensure that we get the new token for the registry
93-
assert!(check_token(TOKEN, None));
94-
}
95-
96-
#[cargo_test]
97-
fn credentials_work_with_extension() {
98-
registry::init();
99-
setup_new_credentials_toml();
100-
101-
cargo_process("login --host")
102-
.arg(registry_url().to_string())
103-
.arg(TOKEN)
104-
.run();
105-
106-
// Ensure that we get the new token for the registry
107-
assert!(check_token(TOKEN, None));
108-
}
109-
110-
#[cargo_test]
111-
fn login_with_old_and_new_credentials() {
112-
setup_new_credentials();
113-
login_with_old_credentials();
114-
}
115-
116-
#[cargo_test]
117-
fn login_without_credentials() {
118-
registry::init();
119-
cargo_process("login --host")
120-
.arg(registry_url().to_string())
121-
.arg(TOKEN)
122-
.run();
123-
124-
// Ensure that we get the new token for the registry
125-
assert!(check_token(TOKEN, None));
126-
}
127-
128-
#[cargo_test]
129-
fn new_credentials_is_used_instead_old() {
130-
registry::init();
131-
setup_new_credentials();
132-
133-
cargo_process("login --host")
134-
.arg(registry_url().to_string())
135-
.arg(TOKEN)
136-
.run();
137-
138-
let mut config = Config::new(Shell::new(), cargo_home(), cargo_home());
139-
let _ = config.values();
140-
let _ = config.load_credentials();
141-
142-
let token = config.get_string("registry.token").unwrap().map(|p| p.val);
143-
assert_eq!(token.unwrap(), TOKEN);
144-
}
145-
14662
#[cargo_test]
14763
fn registry_credentials() {
14864
registry::alt_init();

tests/testsuite/publish.rs

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use cargo_test_support::git::{self, repo};
44
use cargo_test_support::paths;
5-
use cargo_test_support::registry::{self, registry_path, registry_url, Package};
5+
use cargo_test_support::registry::{self, registry_url, Package};
66
use cargo_test_support::{basic_manifest, no_such_file_err_msg, project, publish};
77
use std::fs;
88

@@ -185,57 +185,8 @@ See [..]
185185
validate_upload_foo();
186186
}
187187

188-
// TODO: Deprecated
189-
// remove once it has been decided --host can be removed
190188
#[cargo_test]
191-
fn simple_with_host() {
192-
registry::init();
193-
194-
let p = project()
195-
.file(
196-
"Cargo.toml",
197-
r#"
198-
[project]
199-
name = "foo"
200-
version = "0.0.1"
201-
authors = []
202-
license = "MIT"
203-
description = "foo"
204-
"#,
205-
)
206-
.file("src/main.rs", "fn main() {}")
207-
.build();
208-
209-
p.cargo("publish --no-verify --token sekrit --host")
210-
.arg(registry_url().to_string())
211-
.with_stderr(&format!(
212-
"\
213-
[WARNING] The flag '--host' is no longer valid.
214-
215-
Previous versions of Cargo accepted this flag, but it is being
216-
deprecated. The flag is being renamed to 'index', as the flag
217-
wants the location of the index. Please use '--index' instead.
218-
219-
This will soon become a hard error, so it's either recommended
220-
to update to a fixed version or contact the upstream maintainer
221-
about this warning.
222-
[UPDATING] `{reg}` index
223-
[WARNING] manifest has no documentation, [..]
224-
See [..]
225-
[PACKAGING] foo v0.0.1 ([CWD])
226-
[UPLOADING] foo v0.0.1 ([CWD])
227-
",
228-
reg = registry_path().to_str().unwrap()
229-
))
230-
.run();
231-
232-
validate_upload_foo();
233-
}
234-
235-
// TODO: Deprecated
236-
// remove once it has been decided --host can be removed
237-
#[cargo_test]
238-
fn simple_with_index_and_host() {
189+
fn simple_with_index() {
239190
registry::init();
240191

241192
let p = project()
@@ -255,27 +206,6 @@ fn simple_with_index_and_host() {
255206

256207
p.cargo("publish --no-verify --token sekrit --index")
257208
.arg(registry_url().to_string())
258-
.arg("--host")
259-
.arg(registry_url().to_string())
260-
.with_stderr(&format!(
261-
"\
262-
[WARNING] The flag '--host' is no longer valid.
263-
264-
Previous versions of Cargo accepted this flag, but it is being
265-
deprecated. The flag is being renamed to 'index', as the flag
266-
wants the location of the index. Please use '--index' instead.
267-
268-
This will soon become a hard error, so it's either recommended
269-
to update to a fixed version or contact the upstream maintainer
270-
about this warning.
271-
[UPDATING] `{reg}` index
272-
[WARNING] manifest has no documentation, [..]
273-
See [..]
274-
[PACKAGING] foo v0.0.1 ([CWD])
275-
[UPLOADING] foo v0.0.1 ([CWD])
276-
",
277-
reg = registry_path().to_str().unwrap()
278-
))
279209
.run();
280210

281211
validate_upload_foo();

tests/testsuite/search.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -181,60 +181,6 @@ fn simple() {
181181
.run();
182182
}
183183

184-
// TODO: Deprecated
185-
// remove once it has been decided '--host' can be safely removed
186-
#[cargo_test]
187-
fn simple_with_host() {
188-
setup();
189-
190-
cargo_process("search postgres --host")
191-
.arg(registry_url().to_string())
192-
.with_stderr(
193-
"\
194-
[WARNING] The flag '--host' is no longer valid.
195-
196-
Previous versions of Cargo accepted this flag, but it is being
197-
deprecated. The flag is being renamed to 'index', as the flag
198-
wants the location of the index. Please use '--index' instead.
199-
200-
This will soon become a hard error, so it's either recommended
201-
to update to a fixed version or contact the upstream maintainer
202-
about this warning.
203-
[UPDATING] `[CWD]/registry` index
204-
",
205-
)
206-
.with_stdout_contains(SEARCH_RESULTS)
207-
.run();
208-
}
209-
210-
// TODO: Deprecated
211-
// remove once it has been decided '--host' can be safely removed
212-
#[cargo_test]
213-
fn simple_with_index_and_host() {
214-
setup();
215-
216-
cargo_process("search postgres --index")
217-
.arg(registry_url().to_string())
218-
.arg("--host")
219-
.arg(registry_url().to_string())
220-
.with_stderr(
221-
"\
222-
[WARNING] The flag '--host' is no longer valid.
223-
224-
Previous versions of Cargo accepted this flag, but it is being
225-
deprecated. The flag is being renamed to 'index', as the flag
226-
wants the location of the index. Please use '--index' instead.
227-
228-
This will soon become a hard error, so it's either recommended
229-
to update to a fixed version or contact the upstream maintainer
230-
about this warning.
231-
[UPDATING] `[CWD]/registry` index
232-
",
233-
)
234-
.with_stdout_contains(SEARCH_RESULTS)
235-
.run();
236-
}
237-
238184
#[cargo_test]
239185
fn multiple_query_params() {
240186
setup();

0 commit comments

Comments
 (0)