elixir_git_hooks icon indicating copy to clipboard operation
elixir_git_hooks copied to clipboard

Compilation error when using git worktrees

Open cspags opened this issue 11 months ago • 0 comments

Hi, thanks for the great library!

There's a compile error when attempting to use git_hooks inside a git worktree.

== Compilation error in file lib/git_hooks.ex ==
** (RuntimeError) Could not find .git directory from /<redacted_project_dir>/deps/git_hooks
    lib/git/git_path.ex:17: GitHooks.Git.GitPath.resolve_app_path/0
    lib/mix/tasks/git_hooks/install.ex:48: Mix.Tasks.GitHooks.Install.install/1
    lib/git_hooks.ex:9: (module)

find_git_root/1 uses File.dir?(Path.join(path, ".git"), but inside a worktree folder .git is a file instead of a directory.

Changing to File.exists?(Path.join(path, ".git") seems to fix the issue. Wanted to suggest in case you might consider making the change.

Thank you!

cspags avatar Dec 29 '25 22:12 cspags