Skip to content

Commit 4aa17ed

Browse files
committed
Auto merge of #7588 - TransmissionsDev:master, r=alexcrichton
Remove "cargo login" from user input when asking for login token. Hey all! This is my first time contributing to open source, but I realized that I could help some people out and make a quick change. 😄 When running cargo login, I was told to `please visit https://crates.io/me and paste the API Token below`. However, me on autopilot accidentally pasted the whole `cargo login $APITOKEN` string on the website into `cargo login` and it took me almost 30 minutes to figure out why I couldn't publish a package. I thought it would be useful to automatically remove `cargo login` from the token, just in case someone makes the brain dead mistake like me. Hope I can get some good feedback on this, have a great one! ❤️
2 parents 3738e1d + 648b39e commit 4aa17ed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cargo/ops/registry.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
439439
if let Some(check) = http.check_revoke {
440440
handle.ssl_options(SslOpt::new().no_revoke(!check))?;
441441
}
442+
442443
if let Some(user_agent) = &http.user_agent {
443444
handle.useragent(user_agent)?;
444445
} else {
@@ -603,7 +604,8 @@ pub fn registry_login(
603604
.read_line(&mut line)
604605
.chain_err(|| "failed to read stdin")
605606
.map_err(failure::Error::from)?;
606-
line.trim().to_string()
607+
// Automatically remove `cargo login` from an inputted token to allow direct pastes from `registry.host()`/me.
608+
line.replace("cargo login", "").trim().to_string()
607609
}
608610
};
609611

0 commit comments

Comments
 (0)