Skip to content

Remove git2 dependency #934

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,881 changes: 1,218 additions & 663 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 37 additions & 7 deletions hipcheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ env_logger = { version = "0.11.6" }
flate2 = "1.1.0"
fs_extra = "1.3.0"
futures = "0.3.31"
# Vendor libgit2 and openssl so that they will be statically included
# and not cause problems on certain systems that might not have one or
# the other.
git2 = { version = "0.20.1", features = [
"vendored-libgit2",
"vendored-openssl",
gix = { version = "0.71.0", default-features = false, features = [
"basic",
"dirwalk",
"worktree-mutation",
"max-control",
# use reqwest/rustls to avoid needing openssl
"blocking-http-transport-reqwest-rust-tls",
"zlib-stock",
] }
# Include with both a `path` and `version` reference.
# Local builds will use the `path` dependency, which may be a newer
Expand All @@ -77,6 +79,15 @@ num-traits = "0.2.19"
ordered-float = { version = "5.0.0", features = ["serde"] }
packageurl = "0.4.1"
pathbuf = "1.0.0"
prodash = { version = "29.0.0", default-features = false, features = [
"render-line",
"render-line-autoconfigure",
"render-line-crossterm",
"unit-bytes",
"unit-duration",
"unit-human",
] }
prost = "0.13.5"
rand = "0.9.0"
rayon = "1.10.0"
regex = "1.11.1"
Expand Down Expand Up @@ -108,7 +119,14 @@ strum_macros = "0.27.1"
tabled = "0.18.0"
tar = "0.4.44"
tempfile = "3.17.1"
tokio = { version = "1.44.1", features = ["rt", "rt-multi-thread", "sync", "time", "process", "fs"] }
tokio = { version = "1.44.1", features = [
"rt",
"rt-multi-thread",
"sync",
"time",
"process",
"fs",
] }
tokio-stream = "0.1.17"
toml = "0.8.20"
tonic = "0.13.0"
Expand All @@ -131,6 +149,18 @@ serde_with = "3.12.0"
hipcheck-workspace-hack = { version = "0.1", path = "../library/hipcheck-workspace-hack" }
gomod-rs = "0.1.1"

# This is needed to force reqwest, which is used by gix, to build reqwest with support
# for rustls-tls-native-roots, which is needed to automatically configure system certificates
[dependencies.reqwest]
version = "0.12"
default-features = false
features = [
"blocking",
"http2",
"rustls-tls-native-roots",
"macos-system-configuration",
]

[build-dependencies]

anyhow = "1.0.97"
Expand Down
14 changes: 5 additions & 9 deletions hipcheck/src/cache/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use crate::{error::Result, hc_error};
use dialoguer::Confirm;
use git2::Repository;
use pathbuf::pathbuf;
use regex::Regex;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -162,15 +161,12 @@ impl HcRepoCacheIterator {
.to_str()
.unwrap()
.to_owned();
let repo = Repository::open(path)?;
let commit = repo
let commit = gix::open(path)?
.head()?
.peel_to_commit()?
.as_object()
.short_id()?
.as_str()
.unwrap()
.to_owned();
.id()
.ok_or_else(|| hc_error!("HEAD does not have an ID"))?
.shorten()?
.to_string();
let modified = get_last_modified_or_now(path);
let cache_subdir = pathbuf![path.strip_prefix(self.root.as_path()).unwrap()];
let mut parent = cache_subdir.clone();
Expand Down
34 changes: 0 additions & 34 deletions hipcheck/src/init/git2_log_shim.rs

This file was deleted.

219 changes: 0 additions & 219 deletions hipcheck/src/init/git2_rustls_transport.rs

This file was deleted.

14 changes: 0 additions & 14 deletions hipcheck/src/init/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

mod git2_log_shim;
mod git2_rustls_transport;
mod indicatif_log_bridge;

use crate::shell::{verbosity::Verbosity, Shell};
Expand All @@ -15,7 +13,6 @@ use rustls::crypto::{ring, CryptoProvider};
pub fn init() {
init_shell();
init_logging();
init_libgit2();
init_cryptography();
init_software_versions();
}
Expand All @@ -32,17 +29,6 @@ fn init_logging() {
.expect("logging initialization must succeed");
}

fn init_libgit2() {
// Tell the `git2` crate to pass its tracing messages to the log crate.
git2_log_shim::git2_set_trace_log_shim();

// Make libgit2 use a rustls + ureq based transport for executing the git
// protocol over http(s). I would normally just let libgit2 use its own
// implementation but have seen that this rustls/ureq transport is 2-3 times
// faster on my machine — enough of a performance bump to warrant using this.
git2_rustls_transport::register();
}

fn init_cryptography() {
// Install a process-wide default crypto provider.
CryptoProvider::install_default(ring::default_provider())
Expand Down
Loading