-
Notifications
You must be signed in to change notification settings - Fork 900
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 Git dependencies #283
Conversation
bf0a2c8
to
2519334
Compare
crates/puffin-vcs/src/git.rs
Outdated
@@ -0,0 +1,1367 @@ | |||
/// Git support is derived from Cargo's implementation. |
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.
This file does the actual Git operations. It's largely derived from Cargo.
2519334
to
8a52fe5
Compare
crates/puffin-vcs/src/source.rs
Outdated
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This would not remove our dependency on libgit2
since this is just the fetch.)
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 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
git
module to perform the cloning, which is based onlibgit2
.As compared to Cargo's implementation, I made the following changes:
curl
, in favor ofreqwest
which we use elsewhere.gix
. Cargo allows the use ofgix
as an experimental flag, but it only supports a small subset of the operations. When Cargo fully adoptsgix
, we should plan to do the same.indicatif
and 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.