-
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
Add a new CARGO_PKG_AUTHORS environment variable #2465
Conversation
Something that has been touched upon in #2441 is how to format authors. I've gone with a |
Looks reasonable to me, thanks @TheNeikos! Curious what others on @rust-lang/tools think as well! |
Ok, got a chance to talk about this with @wycats yesterday, and the conclusion is that this seems fine to add, but for lists we probably want to go with colon-separated? Seems less likely to have a colon in the name at least other than a comma. |
@alexcrichton Less likely, but still possible. What about using the standard email format: Some Name some.name@example.org, "Last, First" first.last@example.com That format handles any kind of punctuation, and seems closer to what people expect with a list of names and emails. |
Oh this isn't necessarily for the format itself, moreso for joining two different names together (you can have multiple authors). |
@alexcrichton That's what I mean. If someone puts this into Cargo.toml:
then the environment variable could contain If someone decided, for whatever reason, to have an author entry like |
So, a colon it is then?
Would then be: Asking to clarify. This should also work for the concerns @joshtriplett brought up I think? |
@joshtriplett yeah although @wycats was thinking we'd use a colon instead of a comma. We currently don't have a macro to parse this out and it's possible for someone to say something like: authors = ["foo:bar", "baz"] where if we use a colon separator this would look like |
@alexcrichton How easily can we scan the entire ecosystem of Cargo.toml files and find out whether anyone currently uses a comma or colon in the Authors field? If Cargo bans a character there, then you can use anything you want. Otherwise, you'd want some kind of quoting/escaping, and for that, following rfc5322/rfc2822/rfc822 convention for "mailbox-list" seems like the right approach, along with requiring that each quoted string in the authors list follow the convention for one "mailbox". I feel certain that Rust has at least one compliant parser for that format, and generating it is relatively easy. |
Looks like colons and commas show up unfortunately. Colons show up in some HTTP addresses in the authors field and commas separate either names or multiple email addresses. |
@alexcrichton Odd to see HTTP URLs in the authors field; are people putting things like Regarding comma-separated names and email addresses: isn't the field a list? Are people writing |
Yeah that's basically what I saw from a quick grep, some names look like "last, first " I think. |
@alexcrichton Yeah, some businesses do that even in email headers: "Last, First" first.last@example.com What about just escaping the names in a consistent way (for instance, always wrap them in single-quotes, and escape single-quotes and backslashes with backslashes), and then putting them in the environment variable separated by anything we like? That's easy enough to reverse back into a list of strings. |
The problem with creating our own syntax for this is then you end up needing to create a parser as well. We've tended to avoid that in the past for things like |
☔ The latest upstream changes (presumably #2531) made this pull request unmergeable. Please resolve the merge conflicts. |
07233f6
to
2a10d69
Compare
@alexcrichton Is this what was decided? Or should I put in some whitespace as well? |
@@ -45,6 +45,7 @@ let version = env!("CARGO_PKG_VERSION"); | |||
* `CARGO_PKG_VERSION_MINOR` - The minor version of your package. | |||
* `CARGO_PKG_VERSION_PATCH` - The patch version of your package. | |||
* `CARGO_PKG_VERSION_PRE` - The pre-release version of your package. | |||
* `CARGO_PKG_AUTHORS` - Comma seperated list of authors from the manifest of your package. |
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.
The "comma separated" part here may no longer be right
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.
Oops you're right! Changed it in the commit, but forget here. On it.
Looks good to me! Just a minor nit |
This will allow crates to use the CARGO_PKG_AUTHORS env variable to get a colon seperated list of the authors declared in the manifest. Closes rust-lang#2441
2a10d69
to
dd26ce3
Compare
Add a new CARGO_PKG_AUTHORS environment variable This will allow crates to use the CARGO_PKG_AUTHORS env variable to get a comma seperated list of the authors declared in the manifest. Closes #2441
☀️ Test successful - cargo-cross-linux, cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-gnu-64, cargo-win-msvc-32, cargo-win-msvc-64 |
This will allow crates to use the CARGO_PKG_AUTHORS env variable to get a comma
seperated list of the authors declared in the manifest.
Closes #2441