Add support for Git dependencies#283
Conversation
bf0a2c8 to
2519334
Compare
| @@ -0,0 +1,1367 @@ | |||
| /// Git support is derived from Cargo's implementation. | |||
There was a problem hiding this comment.
This file does the actual Git operations. It's largely derived from Cargo.
2519334 to
8a52fe5
Compare
| .join(short_id.as_str()); | ||
| db.copy_to(actual_rev, &checkout_path, self.strategy, &self.client)?; | ||
|
|
||
| Ok(checkout_path) |
There was a problem hiding this comment.
The cool thing about Cargo's implementation is that they maintain a "database" of repositories. So every repository that you ever check out is included in there. Then, peer to it, they have a directory of checkouts, which are created by checking out the commit in the database and hardlinking from the database to the checkout. So it's fast to switch between commits of the same repository.
e075b5f to
bed2256
Compare
|
|
||
| debug!("Performing a Git fetch for: {remote_url}"); | ||
| match strategy { | ||
| FetchStrategy::Cli => fetch_with_cli(repo, remote_url, &refspecs, tags), |
There was a problem hiding this comment.
There are so many issues about Cargo not working as expected with SSH dependencies that I'm wondering if we should just make this the default (rust-lang/cargo#2078, rust-lang/cargo#3381, etc.).
There was a problem hiding this comment.
(This would not remove our dependency on libgit2 since this is just the fetch.)
konstin
left a comment
There was a problem hiding this comment.
I didn't review the parts copied from cargo.
It's a pity that we copy the code and there's no reusable crate.
|
@konstin - I agree although I'm actually happy with how little code we had to copy in the end. It may not feel that way from the review, but I was able to pare it down a lot. Now, we're really only borrowing the actual Git operations and logic around when to refresh, when to reset, recursively cloning submodules, etc., which at least feels somewhat domain agnostic. |
bed2256 to
0b41988
Compare
Summary
This PR adds support for Git dependencies, like:
Right now, they're only supported in the resolver (and not the installer), since the installer doesn't yet support source distributions at all.
The general approach here is based on Cargo's Git implementation. Specifically, I adapted Cargo's
gitmodule to perform the cloning, which is based onlibgit2.As compared to Cargo's implementation, I made the following changes:
curl, in favor ofreqwestwhich we use elsewhere.gix. Cargo allows the use ofgixas an experimental flag, but it only supports a small subset of the operations. When Cargo fully adoptsgix, we should plan to do the same.indicatifand Cargo had their own thing.There are a few follow-ups to consider:
I'll work on the latter two in follow-up PRs.
Closes #202.