-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix overwriting alternate registry token #7708
Conversation
When executing `cargo login`, 2nd alternate registry token overwrites 1st alternate registry token. Fixes rust-lang#7701.
r? @ehuss (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think it would be best to avoid creating a second registry unconditionally in all tests, since it affects hundreds of tests (creating thousands of extra files). Perhaps some changes like this:
- Move the code for creating a registry into a separate function (so it is not repeated 3 times).
- Instead of adding "alt2" functions, add functions with a parameter (like
registry_path(name)
), and have the existing functions call that instead. - Change
registry_credentials
so that is the only place where the second registry is created. It can modify the.cargo/config
file with the[registries]
definitions as needed.
Thank you for reviewing! As you say, it seems better to avoid creating a second registry in the other tests, so I fix it. Could you review this again? I will squashed these commits at the end. |
fn generate_dl_url(name: &str) -> String { | ||
let base = Url::from_file_path(generate_path(name)).ok().unwrap(); | ||
format!("{}/{{crate}}/{{version}}/{{crate}}-{{version}}.crate", base) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can all the other functions (the alt_*
functions) be changed to call these new functions instead of duplicating the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I fixed it like that. I also corrected registry_path
function etc., but is this OK?
|
||
[registries.alternative2] | ||
index = '{alt2}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to not set this here, and only set it in the registry_credentials
test. Can probably just append to the config file.
@@ -214,6 +229,23 @@ pub fn init() { | |||
fs::create_dir_all(alt_api_path().join("api/v1/crates")).unwrap(); | |||
} | |||
|
|||
pub fn init_alt2_registry() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be written so that the other two registries reuse the same code instead of duplicating it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced this with a new function init_registry
and the existing codes for creating registry call the new function. I am a little worried that there are many arguments for this new function, but I couldn't come up with another good way to write it.
tests/testsuite/login.rs
Outdated
.arg("-Zunstable-options") | ||
.masquerade_as_nightly_cargo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two lines can be removed, I think we just forgot to remove them when stabilized. And remove the same 2 lines in the call above.
Looks good to me, thanks! @bors r+ |
📌 Commit b7bc069 has been approved by |
Fix overwriting alternate registry token When executing `cargo login`, 2nd alternate registry token overwrites 1st alternate registry token. Fixes #7701.
☀️ Test successful - checks-azure |
When executing
cargo login
, 2nd alternate registry token overwrites1st alternate registry token.
Fixes #7701.