Skip to content

Commit

Permalink
fix: allow .git directory on parent directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Roman Gonzalez committed Jan 30, 2023
1 parent 7bdf85f commit 3973f37
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ in
if ! type -t git >/dev/null; then
# This happens in pure shells, including lorri
echo 1>&2 "WARNING: pre-commit-hooks.nix: git command not found; skipping installation."
elif [[ ! -e .git ]]; then
elif ! ${git}/bin/git rev-parse --git-dir &> /dev/null; then
echo 1>&2 "WARNING: pre-commit-hooks.nix: .git not found; skipping installation."
else
# These update procedures compare before they write, to avoid
Expand Down

0 comments on commit 3973f37

Please sign in to comment.