diff --git a/Cargo.lock b/Cargo.lock index fd67538a2..b52e9b420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4955,12 +4955,12 @@ dependencies = [ "uv-cache-info", "uv-cache-key", "uv-distribution-types", + "uv-git", "uv-normalize", "uv-pep440", "uv-pep508", "uv-platform-tags", "uv-static", - "which", ] [[package]] diff --git a/crates/uv-configuration/Cargo.toml b/crates/uv-configuration/Cargo.toml index c27ad4276..1c195ab3d 100644 --- a/crates/uv-configuration/Cargo.toml +++ b/crates/uv-configuration/Cargo.toml @@ -21,6 +21,7 @@ uv-cache = { workspace = true } uv-cache-info = { workspace = true } uv-cache-key = { workspace = true } uv-distribution-types = { workspace = true } +uv-git = { workspace = true } uv-normalize = { workspace = true } uv-pep440 = { workspace = true } uv-pep508 = { workspace = true, features = ["schemars"] } @@ -40,7 +41,6 @@ serde_json = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } url = { workspace = true } -which = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/crates/uv-configuration/src/vcs.rs b/crates/uv-configuration/src/vcs.rs index 6a56e8f36..4c93dba8c 100644 --- a/crates/uv-configuration/src/vcs.rs +++ b/crates/uv-configuration/src/vcs.rs @@ -4,6 +4,7 @@ use std::process::{Command, Stdio}; use serde::Deserialize; use tracing::debug; +use uv_git::GIT; #[derive(Debug, thiserror::Error)] pub enum VersionControlError { @@ -35,7 +36,7 @@ impl VersionControlSystem { pub fn init(&self, path: &Path) -> Result<(), VersionControlError> { match self { Self::Git => { - let Ok(git) = which::which("git") else { + let Ok(git) = GIT.as_ref() else { return Err(VersionControlError::GitNotInstalled); }; @@ -80,17 +81,16 @@ impl VersionControlSystem { /// Detects the VCS system based on the provided path. pub fn detect(path: &Path) -> Option { // Determine whether the path is inside a Git work tree. - if which::which("git").is_ok_and(|git| { - Command::new(git) - .arg("rev-parse") - .arg("--is-inside-work-tree") - .current_dir(path) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status() - .map(|status| status.success()) - .unwrap_or(false) - }) { + let git = GIT.as_ref().ok()?; + let exit_status = Command::new(git) + .arg("rev-parse") + .arg("--is-inside-work-tree") + .current_dir(path) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .ok()?; + if exit_status.success() { return Some(Self::Git); }