Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/uv-configuration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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 }
Expand Down
24 changes: 12 additions & 12 deletions crates/uv-configuration/src/vcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
};

Expand Down Expand Up @@ -80,17 +81,16 @@ impl VersionControlSystem {
/// Detects the VCS system based on the provided path.
pub fn detect(path: &Path) -> Option<Self> {
// 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);
}

Expand Down
Loading