Skip to content

Commit

Permalink
cli/fs: just check if dir exists for submodule
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PgBiel committed Apr 24, 2024
1 parent a8a55dd commit 313c705
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler-cli/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}
Expand Down

0 comments on commit 313c705

Please sign in to comment.