Skip to content

Commit

Permalink
Fix hooksPath when configured from a subdirectory
Browse files Browse the repository at this point in the history
Resolves #358.
  • Loading branch information
sandydoo committed Nov 15, 2023
1 parent ea758da commit a22a571
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,14 @@ in
else
pre-commit install
fi
${git}/bin/git config --local core.hooksPath "$(${git}/bin/git rev-parse --git-common-dir)/hooks"
# Fetch the absolute path to the git common directory. This will normally point to $GIT_WC/.git.
common_dir=''$(${git}/bin/git rev-parse --path-format=absolute --git-common-dir)
# Convert the absolute path to a path relative to the toplevel working directory.
common_dir=''${common_dir#''$GIT_WC/}
${git}/bin/git config --local core.hooksPath "''$common_dir/hooks"
fi
fi
fi
Expand Down

0 comments on commit a22a571

Please sign in to comment.