diff --git a/crates/prek/src/fs.rs b/crates/prek/src/fs.rs index ee4a469eb..8c7321f22 100644 --- a/crates/prek/src/fs.rs +++ b/crates/prek/src/fs.rs @@ -33,8 +33,11 @@ use tracing::{debug, error, info, trace}; use crate::cli::reporter; -pub static CWD: LazyLock = - LazyLock::new(|| std::env::current_dir().expect("The current directory must be exist")); +pub static CWD: LazyLock = LazyLock::new(|| { + std::env::current_dir() + .map(|cwd| dunce::canonicalize(&cwd).unwrap_or(cwd)) + .expect("The current directory must be exist") +}); static IN_PROCESS_LOCK_HELD_COUNTS: LazyLock>> = LazyLock::new(Default::default); diff --git a/crates/prek/src/git.rs b/crates/prek/src/git.rs index 9a72b285a..763e78cee 100644 --- a/crates/prek/src/git.rs +++ b/crates/prek/src/git.rs @@ -34,9 +34,11 @@ pub(crate) static GIT: LazyLock> = LazyLock::new(|| which::which("git")); pub(crate) static GIT_ROOT: LazyLock> = LazyLock::new(|| { - get_root().inspect(|root| { - debug!("Git root: {}", root.display()); - }) + get_root() + .map(|root| dunce::canonicalize(&root).unwrap_or(root)) + .inspect(|root| { + debug!("Git root: {}", root.display()); + }) }); /// Remove some `GIT_` environment variables exposed by `git`.