From 313c705cc1d62b93c8a9611b8ab5511c6e19856b Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:27:24 -0300 Subject: [PATCH] cli/fs: just check if dir exists for submodule The previous check would only return false if the dir didn't exist. If it did, it would be inside the repository we initialized earlier, so it would indeed be inside a Git worktree. And checking for a Git worktree on a directory that doesn't exist seems to error on Windows. --- compiler-cli/src/fs.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler-cli/src/fs.rs b/compiler-cli/src/fs.rs index cd50dabca..0a140b82a 100644 --- a/compiler-cli/src/fs.rs +++ b/compiler-cli/src/fs.rs @@ -685,7 +685,13 @@ pub fn git_submodule_add( ) -> Result<(), Error> { tracing::trace!(submodule=?name, repo=?url, path=?path, "cloning package as submodule"); - if is_inside_git_work_tree(&root.join(path))? { + let submodule_path = root.join(path); + if submodule_path.try_exists().map_err(|e| Error::FileIo { + kind: FileKind::Directory, + action: FileIoAction::ReadMetadata, + path: submodule_path, + err: Some(e.to_string()), + })? { tracing::trace!(path=?path, "package_already_cloned"); return Ok(()); }