-
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
Support vendoring git repositories #3992
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
None => { | ||
match try("rev")? { | ||
Some(b) => GitReference::Rev(b.0.to_string()), | ||
None => GitReference::Branch("master".to_string()), |
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.
Wasn't there a bug somewhere that we shouldn't hardcode master, because it might not be the default branch?
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.
Hm I can't seem to locate that isue but it sounds familiar. Do you think it's better to fix the bug here or differ from git sources in the manifest? I'd lean a bit towards mirroring git sources ...
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 not fixed yet (I was not sure about it), so it's better to be consistent with our behavior elsewhere.
Looks like the proper fix is to add a new HEAD
variant to the GitRefernce
enum, and it's to much work for this PR.
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.
Ah yeah thanks for the link! And yeah falling back to HEAD
seems like a reasonable implementation to me.
src/cargo/sources/config.rs
Outdated
bail!("\ | ||
cannot replace `{orig}` with `{name}`, the source `{supports}` supports \ | ||
checksums, but `{no_support}` does not | ||
|
||
a lock file compatible with `{orig}` cannot be generated in this situation | ||
", orig = orig_name, name = name, supports = supports, no_support = no_support); | ||
", orig = orig_name, name = name, supports = orig_name, no_support = name); |
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.
We don't need supports
and no_support
keys any more, may just use orig
and name
(or replaced
)
@alexcrichton could you explain how cheksums work (they are created in
So the package is |
Sure yeah, so right now every source in Cargo can report whether it supports checksums or not. This basically means that the There were two pieces that needed to be changed to allow this implementation:
You're correct in that it's still intended that vendored sources are not allowed to have modifications. The
Oh but the .crate file isn't actually in the directory, (that's why we can't calculate it at runtime). |
Looks good to me! (modulo the fact that I have not yet fully wrapped my mind around |
FWIW I'd like to hold off on merging this just yet, I'd ideally prefer to implement support in cargo-vendor first and make sure that works out well. |
☔ The latest upstream changes (presumably #4026) made this pull request unmergeable. Please resolve the merge conflicts. |
Currently the vendoring support in Cargo primarily only allows replacing registry sources, e.g. crates.io. Other networked sources of code, such as git repositories, cannot currently be replaced. The purpose of this commit is to support vendoring of git dependencies to eventually have support implemented in the `cargo-vendor` subcommand. Support for vendoring git repositories required a few subtle changes: * First and foremost, configuration for source replacement of a git repository was added. This looks similar to the `Cargo.toml` configuration of a git source. * The restriction around checksum providing sources was relaxed. If a replacement source provides checksums but the replaced source doesn't then that's now considered ok unlike it being an error before. * Lock files can be generated for crates.io crates against vendored sources, but lock files cannot be generated against git sources. A lock file must previously exist to make use of a vendored git source. * The `package` field of `.cargo-checksum.json` is now optional, and it is intended to be omitted for git sources that are vendored.
c975b37
to
5b08b8f
Compare
Ok this is rebased now and cargo-vendor is ready to go, so I'm going to r+.. @bors: r=matklad |
📌 Commit 5b08b8f has been approved by |
Support vendoring git repositories Currently the vendoring support in Cargo primarily only allows replacing registry sources, e.g. crates.io. Other networked sources of code, such as git repositories, cannot currently be replaced. The purpose of this commit is to support vendoring of git dependencies to eventually have support implemented in the `cargo-vendor` subcommand. Support for vendoring git repositories required a few subtle changes: * First and foremost, configuration for source replacement of a git repository was added. This looks similar to the `Cargo.toml` configuration of a git source. * The restriction around checksum providing sources was relaxed. If a replacement source provides checksums but the replaced source doesn't then that's now considered ok unlike it being an error before. * Lock files can be generated for crates.io crates against vendored sources, but lock files cannot be generated against git sources. A lock file must previously exist to make use of a vendored git source. * The `package` field of `.cargo-checksum.json` is now optional, and it is intended to be omitted for git sources that are vendored.
☀️ Test successful - status-appveyor, status-travis |
Currently the vendoring support in Cargo primarily only allows replacing
registry sources, e.g. crates.io. Other networked sources of code, such as git
repositories, cannot currently be replaced. The purpose of this commit is to
support vendoring of git dependencies to eventually have support implemented in
the
cargo-vendor
subcommand.Support for vendoring git repositories required a few subtle changes:
First and foremost, configuration for source replacement of a git repository
was added. This looks similar to the
Cargo.toml
configuration of a gitsource.
The restriction around checksum providing sources was relaxed. If a
replacement source provides checksums but the replaced source doesn't then
that's now considered ok unlike it being an error before.
Lock files can be generated for crates.io crates against vendored sources, but
lock files cannot be generated against git sources. A lock file must
previously exist to make use of a vendored git source.
The
package
field of.cargo-checksum.json
is now optional, and it isintended to be omitted for git sources that are vendored.