Skip to content
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 support for a default registry for cargo commands #6135

Merged
merged 4 commits into from
Oct 8, 2018

Conversation

cswindle
Copy link
Contributor

@cswindle cswindle commented Oct 5, 2018

This adds two things:

  • --registry support for new and init
  • adds default registry configuration to cargo

The main reason for these changes is to reduce the risk of closed-source software ending up accidentally on crates.io.

This fixes #6123.

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @sfackler, do you have any objections to this?

src/cargo/ops/cargo_new.rs Outdated Show resolved Hide resolved
@@ -359,9 +360,22 @@ pub trait ArgMatchesExt {
requires -Zunstable-options to use."
));
}
Ok(Some(registry.to_string()))

if registry == "crates.io" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be one of the few places that we accept this string, right? If so, could the special casing not be done here and perhaps later in a more centralized location?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit - crates-io is used rather than crates.io in [patch] blocks so it might make sense to use the same here for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be one of the few places that we accept this string, right? If so, could the special casing not be done here and perhaps later in a more centralized location?

I have made the string a constant (and updated other uses of it), so it is now just doing a string comparison, I did consider moving the logic into source_id, but we don't always need the source (for example in publish), so I have left it where it was. Is that ok?

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Oct 8, 2018

📌 Commit 1fd3f1b has been approved by alexcrichton

@bors
Copy link
Collaborator

bors commented Oct 8, 2018

⌛ Testing commit 1fd3f1b with merge 5dbac98...

bors added a commit that referenced this pull request Oct 8, 2018
Add support for a default registry for cargo commands

This adds two things:
  - --registry support for new and init
 - adds default registry configuration to cargo

The main reason for these changes is to reduce the risk of closed-source software ending up accidentally on crates.io.

This fixes #6123.
@bors
Copy link
Collaborator

bors commented Oct 8, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 5dbac98 to master...

@bors bors merged commit 1fd3f1b into rust-lang:master Oct 8, 2018
@ehuss ehuss added this to the 1.31.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crates can easily be published to crates.io accidentally when using alternative registries
6 participants