Skip to content

Commit c67006f

Browse files
author
Roman Gonzalez
committed
fix: allow .git directory on parent directory
Currently, the check to validate pre-commit-hooks are getting installed on a git repository only consider the `.git` directory, if the pre-commit-hooks config lives in another path that is not the root of the repository, pre-commit-hooks won't install a script. This change allows flake.nix files in sub-directories to have the pre-commit-hooks configuration. This is specially common in monorepos.
1 parent f8992fb commit c67006f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/pre-commit.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ in
366366
if ! type -t git >/dev/null; then
367367
# This happens in pure shells, including lorri
368368
echo 1>&2 "WARNING: pre-commit-hooks.nix: git command not found; skipping installation."
369-
elif [[ ! -e .git ]]; then
369+
elif ! ${pkgs.locate-dominating-file}/bin/locate-dominating-file .git >/dev/null; then
370370
echo 1>&2 "WARNING: pre-commit-hooks.nix: .git not found; skipping installation."
371371
else
372372
# These update procedures compare before they write, to avoid

0 commit comments

Comments
 (0)