Skip to content

Commit

Permalink
Remove warnings about old configuration on publish.
Browse files Browse the repository at this point in the history
  • Loading branch information
fa7ca7 committed Jun 1, 2017
1 parent 7c515a0 commit 903be77
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 38 deletions.
8 changes: 0 additions & 8 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
opts.config.shell().status("Uploading", pkg.package_id().to_string())?;
transmit(opts.config, pkg, tarball.file(), &mut registry, opts.dry_run)?;

if opts.config.is_token_in_main_config() {
let _ = opts.config
.shell()
.warn("API token detected in ~/.cargo/config under `registry.token`.\n \
You should remove it and do `login` again in order to \
save token in ~/.cargo/credentials");
}

Ok(())
}

Expand Down
28 changes: 0 additions & 28 deletions src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ pub struct Config {
extra_verbose: Cell<bool>,
frozen: Cell<bool>,
locked: Cell<bool>,

// A temporary solution to point on an old configuration's usage.
// If it's true cargo will warn on it on publish.
token_in_main_config: Cell<bool>,
}

impl Config {
Expand All @@ -55,7 +51,6 @@ impl Config {
extra_verbose: Cell::new(false),
frozen: Cell::new(false),
locked: Cell::new(false),
token_in_main_config: Cell::new(false),
}
}

Expand Down Expand Up @@ -408,10 +403,6 @@ impl Config {
!self.frozen.get() && !self.locked.get()
}

pub fn is_token_in_main_config(&self) -> bool {
self.token_in_main_config.get()
}

pub fn load_values(&self) -> CargoResult<HashMap<String, ConfigValue>> {
let mut cfg = CV::Table(HashMap::new(), PathBuf::from("."));

Expand All @@ -438,8 +429,6 @@ impl Config {
Ok(())
}).chain_err(|| "Couldn't load Cargo configuration")?;

self.token_in_main_config.set(check_token_in_main_config("registry.token".into(), &cfg));

let mut map = match cfg {
CV::Table(map, _) => map,
_ => unreachable!(),
Expand Down Expand Up @@ -823,20 +812,3 @@ fn load_credentials(home: &PathBuf) -> CargoResult<Option<String>> {

Ok(Some(token.trim().into()))
}

fn check_token_in_main_config(key: &str, cfg: &ConfigValue) -> bool {
let mut keys = key.split('.');
let k = keys.next().unwrap();
let keys: String = keys.map(String::from).collect();

match *cfg {
CV::Table(ref map, _) => {
match map.get(k) {
Some(ref v) => check_token_in_main_config(keys.as_str(), v),
None => return false,
}
}
CV::String(ref v, _) => !v.is_empty(),
_ => return false,
}
}
4 changes: 2 additions & 2 deletions tests/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn simple() {

assert_that(p.cargo_process("publish").arg("--no-verify")
.arg("--host").arg(registry().to_string()),
execs().with_status(0).with_stderr_contains(&format!("\
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[WARNING] manifest has no documentation, [..]
See [..]
Expand Down Expand Up @@ -371,7 +371,7 @@ fn dry_run() {

assert_that(p.cargo_process("publish").arg("--dry-run")
.arg("--host").arg(registry().to_string()),
execs().with_status(0).with_stderr_contains(&format!("\
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[WARNING] manifest has no documentation, [..]
See [..]
Expand Down

0 comments on commit 903be77

Please sign in to comment.