-
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
Display registry name instead of registry URL when possible #9632
Conversation
r? @Eh2406 (rust-highfive has picked a reviewer for you, use r? to override) |
format!("{:?}", pkg_id) | ||
); | ||
|
||
let expected = r#" | ||
PackageId { | ||
name: "foo", | ||
version: "1.0.0", | ||
source: "registry `https://github.com/rust-lang/crates.io-index`", | ||
source: "registry `crates-io`", |
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.
Why not keep the original registry url instead of using a short alias?
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.
It's the intent of #6691, which make it less mess in terminal (maybe?). And yes it gets some rooms for deciding whether URL should be hidden.
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 isn't an issue since it's less than 80 characters which terminal will usually expect to be the lowest, of course it can go lower but most stuff will look ugly.
Updating `https://gitlab.com/xxxxxxxxxx/cargo/crates-index` index
If a short alias is used some amount of information is hidden which could be useful in the logs.
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.
Yep. Maybe we can preserve the original behaviour of crates.io, and shorten other custom registries, since we have no idea which contains sensitive information. Is this more reasonable?
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.
Is the url sensitive? If it is sensitive shouldn't the user hide it themselves? I think it is not easily missed as it is at the top line, and it does not contain any credentials.
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 got the point and totally agreed. It's very reasonable not using short alias. Let's await the opinion from others. Maybe we can come up with better solution.
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'm a bit confused about the question here. Are you just talking about the debug display? That is almost never shown anywhere, so I'm not sure it really matters. It'll probably be safer to keep the short name (like if asked to share CARGO_LOG
output). If I'm misunderstanding, can you clarify?
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.
Not just debug display, it affects the default cargo display as well. Rather than showing the crates url it shows crates-io
.
☔ The latest upstream changes (presumably #9665) made this pull request unmergeable. Please resolve the merge conflicts. |
Thanks! I'm always a bit nervous changing the behavior of Overall I think the names look cleaner, so 👍 from me. @bors r+ |
📌 Commit b7135644b3a39db3477927e9cd4cb249c9f2e963 has been approved by |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
Oops, didn't see the conflicting file. Can you rebase? @bors r- |
This fixes most messages to display registry names instead of URLs.
Since current lockfile does not serialize any registry names. We here try best effort to restore registry name from either `[registries]` table or `[source]` replacement table. This is done by manually implementing `Hash` and `PartialEq` for `SourceIdInner`, of which two traits previously are simply `derive`d. To make `SourceIdInner` generate the same hash whether contains `name` field or not, here we remove `name` field from hashing and only concern about `kind`, `precise` and `canonical_url`.
Rebased. Thanks for your review @ehuss 😄 |
@bors r+ |
📌 Commit 8c75e2f has been approved by |
☀️ Test successful - checks-actions |
Update cargo 2 commits in 4e143fd131e0c16cefd008456e974236ca54e62e..cebef2951ee69617852844894164b54ed478a7da 2021-07-20 21:55:45 +0000 to 2021-07-22 13:01:52 +0000 - Changes rustc argument from `--force-warns` to `--force-warn` (rust-lang/cargo#9714) - Display registry name instead of registry URL when possible (rust-lang/cargo#9632)
Fixes #6691
This PR can be divided into several parts:
impl Dipslay for SourceId
. This benefits almost all kinds of messages usingSourceId
directly or indrectly.Updating <name> index
part of[source]
replacement, which previously didn't preserve the registry name information.Cargo.lock
. Since current lockfile format does not serialize any registry name. We here try the best effort to restore registry name from either[registries]
table or[source]
replacement table. This is done by manually implementingHash
andPartialEq
forSourceIdInner
, of which two traits previously are simply derived.To make
SourceIdInner
generate the same hash no matter it containsname
field or not, here we removename
field from hashing and only concern aboutkind
,precise
andcanonical_url
.Feel free to ask me for adding more tests, though I am not sure what tests should be added 😅