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
7 changes: 5 additions & 2 deletions crates/prek/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ use tracing::{debug, error, info, trace};

use crate::cli::reporter;

pub static CWD: LazyLock<PathBuf> =
LazyLock::new(|| std::env::current_dir().expect("The current directory must be exist"));
pub static CWD: LazyLock<PathBuf> = 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<Mutex<FxHashMap<PathBuf, usize>>> =
LazyLock::new(Default::default);
Expand Down
8 changes: 5 additions & 3 deletions crates/prek/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ pub(crate) static GIT: LazyLock<Result<PathBuf, which::Error>> =
LazyLock::new(|| which::which("git"));

pub(crate) static GIT_ROOT: LazyLock<Result<PathBuf, Error>> = 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`.
Expand Down
Loading