Skip to content

Commit

Permalink
Port all git functionality to use git CLI (#3833)
Browse files Browse the repository at this point in the history
## Summary

We currently rely on libgit2 for most git-related functionality.
However, libgit2 has long-standing performance issues, as well as lags
significantly behind git in terms of new features. For these reasons we
now use the git CLI by default for fetching repositories
(#1781). This PR completely drops
libgit2 in favor of the git CLI for all git-related functionality, which
should allow us to use features such as partial clones and sparse
checkouts in the future for performance.

There is also a lot of technical debt in the current git code as it's
mostly taken from Cargo. Switching to the git CLI *vastly* simplifies
the `uv-git` codebase.

Eventually we might want to look into switching to
[`gitoxide`](https://github.com/Byron/gitoxide), but it's currently too
immature for our use case.
  • Loading branch information
ibraheemdev authored May 30, 2024
1 parent 85183c1 commit 261aa2c
Show file tree
Hide file tree
Showing 16 changed files with 302 additions and 2,320 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Source distributions can run arbitrary code on build and can make unwanted modif
```bash
docker buildx build -t uv-builder -f builder.dockerfile --load .
# Build for musl to avoid glibc errors, might not be required with your OS version
cargo build --target x86_64-unknown-linux-musl --profile profiling --features vendored-openssl
cargo build --target x86_64-unknown-linux-musl --profile profiling
docker run --rm -it -v $(pwd):/app uv-builder /app/target/x86_64-unknown-linux-musl/profiling/uv-dev resolve-many --cache-dir /app/cache-docker /app/scripts/popular_packages/pypi_10k_most_dependents.txt
```

Expand Down
114 changes: 1 addition & 113 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,8 @@ flate2 = { version = "1.0.28", default-features = false }
fs-err = { version = "2.11.0" }
fs2 = { version = "0.4.3" }
futures = { version = "0.3.30" }
git2 = { version = "0.18.1" }
glob = { version = "0.3.1" }
hex = { version = "0.4.3" }
hmac = { version = "0.12.1" }
home = { version = "0.5.9" }
html-escape = { version = "0.2.13" }
http = { version = "1.1.0" }
indexmap = { version = "2.2.5" }
Expand All @@ -106,7 +103,6 @@ platform-info = { version = "2.0.2" }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "0e684a874c9fb8f74738cd8875524c80e3d4820b" }
pyo3 = { version = "0.21.0" }
pyo3-log = { version = "0.10.0" }
rand = { version = "0.8.5" }
rayon = { version = "1.8.0" }
reflink-copy = { version = "0.1.15" }
regex = { version = "1.10.2" }
Expand All @@ -122,7 +118,6 @@ schemars = { version = "0.8.16", features = ["url"] }
seahash = { version = "4.1.0" }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = { version = "1.0.114" }
sha1 = { version = "0.10.6" }
sha2 = { version = "0.10.8" }
sys-info = { version = "0.9.1" }
tempfile = { version = "3.9.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/distribution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pep508_rs = { workspace = true }
platform-tags = { workspace = true }
pypi-types = { workspace = true }
uv-fs = { workspace = true }
uv-git = { workspace = true, features = ["vendored-openssl"] }
uv-git = { workspace = true }
uv-normalize = { workspace = true }

anyhow = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion crates/pypi-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ uv-normalize = { workspace = true }
uv-git = { workspace = true }

chrono = { workspace = true, features = ["serde"] }
git2 = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }
mailparse = { workspace = true }
once_cell = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/pypi-types/src/parsed_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use thiserror::Error;
use url::{ParseError, Url};

use pep508_rs::{Pep508Url, UnnamedRequirementUrl, VerbatimUrl, VerbatimUrlError};
use uv_git::GitUrl;
use uv_git::{GitUrl, OidParseError};

use crate::{ArchiveInfo, DirInfo, DirectUrl, VcsInfo, VcsKind};

Expand All @@ -20,7 +20,7 @@ pub enum ParsedUrlError {
#[error("Invalid path in file URL: `{0}`")]
InvalidFileUrl(Url),
#[error("Failed to parse Git reference from URL: `{0}`")]
GitShaParse(Url, #[source] git2::Error),
GitShaParse(Url, #[source] OidParseError),
#[error("Not a valid URL: `{0}`")]
UrlParse(String, #[source] ParseError),
#[error(transparent)]
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ uv-cache = { workspace = true }
uv-client = { workspace = true }
uv-extract = { workspace = true }
uv-fs = { workspace = true, features = ["tokio"] }
uv-git = { workspace = true, features = ["vendored-openssl"] }
uv-git = { workspace = true }
uv-normalize = { workspace = true }
uv-types = { workspace = true }
uv-configuration = { workspace = true }
Expand Down
13 changes: 1 addition & 12 deletions crates/uv-git/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,9 @@ cache-key = { workspace = true }
uv-fs = { workspace = true }

anyhow = { workspace = true }
base64 = { workspace = true }
thiserror = { workspace = true }
cargo-util = { workspace = true }
git2 = { workspace = true }
glob = { workspace = true }
hmac = { workspace = true }
home = { workspace = true }
rand = { workspace = true }
reqwest = { workspace = true, features = ["blocking"] }
sha1 = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
fs-err = { workspace = true }

[features]
vendored-libgit2 = ["git2/vendored-libgit2"]
vendored-openssl = ["git2/vendored-openssl"]
Loading

0 comments on commit 261aa2c

Please sign in to comment.