From 25cb79e475deb1bfe0a3d5a6d46c9c9d06b44898 Mon Sep 17 00:00:00 2001 From: KCaverly Date: Tue, 19 Sep 2023 18:55:15 -0400 Subject: [PATCH] remove git2 dependency for repository cloning in semantic_index eval --- Cargo.lock | 19 ------------------ Cargo.toml | 2 +- crates/semantic_index/Cargo.toml | 1 - crates/semantic_index/examples/eval.rs | 27 +++++++++++++------------- 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6753629177..e6dbada745 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3059,8 +3059,6 @@ dependencies = [ "libc", "libgit2-sys", "log", - "openssl-probe", - "openssl-sys", "url", ] @@ -4023,9 +4021,7 @@ checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4" dependencies = [ "cc", "libc", - "libssh2-sys", "libz-sys", - "openssl-sys", "pkg-config", ] @@ -4066,20 +4062,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "libssh2-sys" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - [[package]] name = "libz-sys" version = "1.1.12" @@ -6756,7 +6738,6 @@ dependencies = [ "editor", "env_logger 0.9.3", "futures 0.3.28", - "git2", "globset", "gpui", "isahc", diff --git a/Cargo.toml b/Cargo.toml index 3299986d2c..c1876434ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ toml = { version = "0.5" } tree-sitter = "0.20" unindent = { version = "0.1.7" } pretty_assertions = "1.3.0" -git2 = { version = "0.15" } +git2 = { version = "0.15", default-features = false} tree-sitter-bash = { git = "https://github.com/tree-sitter/tree-sitter-bash", rev = "1b0321ee85701d5036c334a6f04761cdc672e64c" } tree-sitter-c = "0.20.1" diff --git a/crates/semantic_index/Cargo.toml b/crates/semantic_index/Cargo.toml index 2997f5aa0b..44afecb0c2 100644 --- a/crates/semantic_index/Cargo.toml +++ b/crates/semantic_index/Cargo.toml @@ -55,7 +55,6 @@ rust-embed = { version = "8.0", features = ["include-exclude"] } client = { path = "../client" } zed = { path = "../zed"} node_runtime = { path = "../node_runtime"} -git2.workspace = true pretty_assertions.workspace = true rand.workspace = true diff --git a/crates/semantic_index/examples/eval.rs b/crates/semantic_index/examples/eval.rs index 37da380b89..be2a1e8a52 100644 --- a/crates/semantic_index/examples/eval.rs +++ b/crates/semantic_index/examples/eval.rs @@ -1,6 +1,5 @@ use anyhow::{anyhow, Result}; use client::{self, UserStore}; -use git2::{Object, Oid, Repository}; use gpui::{AsyncAppContext, ModelHandle, Task}; use language::LanguageRegistry; use node_runtime::RealNodeRuntime; @@ -11,6 +10,7 @@ use semantic_index::{SearchResult, SemanticIndex}; use serde::{Deserialize, Serialize}; use settings::{default_settings, handle_settings_file_changes, watch_config_file, SettingsStore}; use std::path::{Path, PathBuf}; +use std::process::Command; use std::sync::Arc; use std::time::{Duration, Instant}; use std::{cmp, env, fs}; @@ -95,23 +95,22 @@ fn clone_repo(repo_eval: RepoEval) -> anyhow::Result<(String, PathBuf)> { .ok_or(anyhow!("path canonicalization failed"))? .parent() .unwrap() - .join(TMP_REPO_PATH) - .join(&repo_name); + .join(TMP_REPO_PATH); // Delete Clone Path if already exists let _ = fs::remove_dir_all(&clone_path); + let _ = fs::create_dir(&clone_path); - // Clone in Repo - git2::build::RepoBuilder::new() - // .branch(repo_eval.sha.as_str()) - .clone(repo_eval.repo.as_str(), clone_path.as_path())?; - - let repo: Repository = Repository::open(clone_path.clone())?; - let obj: Object = repo - .find_commit(Oid::from_str(repo_eval.commit.as_str())?)? - .into_object(); - repo.checkout_tree(&obj, None)?; - repo.set_head_detached(obj.id())?; + let _ = Command::new("git") + .args(["clone", repo_eval.repo.as_str()]) + .current_dir(clone_path.clone()) + .output()?; + // Update clone path to be new directory housing the repo. + let clone_path = clone_path.join(repo_name.clone()); + let _ = Command::new("git") + .args(["checkout", repo_eval.commit.as_str()]) + .current_dir(clone_path.clone()) + .output()?; Ok((repo_name, clone_path)) }