Skip to content

Commit 3cfd774

Browse files
committed
prek: fix an issue with prek 0.3.9+ failing to resolve the hooks dir
Prek doesn't like an empty string for `hooksPath`. Fixes #707.
1 parent 580633f commit 3cfd774

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

modules/pre-commit.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ in
510510
for hook in $hooks; do
511511
${lib.getExe cfg.package} uninstall -t $hook
512512
done
513-
${lib.getExe cfg.gitPackage} config --local core.hooksPath ""
513+
# Clear any user-configured core.hooksPath so the hook tool installs into the real hooks dir.
514+
${lib.getExe cfg.gitPackage} config --local --unset-all core.hooksPath || true
514515
# Add hooks for configured stages (only) ...
515516
if [ ! -z "${concatStringsSep " " install_stages}" ]; then
516517
for stage in ${concatStringsSep " " install_stages}; do

nix/tests/installation.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# Test that checks whether the correct hooks are created in the hooks folder.
2-
{ git, perl, coreutils, runCommand, run, lib, mktemp }:
2+
{ git, perl, coreutils, runCommand, run, lib, mktemp, prek }:
33
let
44
tests = {
55
basic-test = {
66
expectedHooks = [ "pre-commit" ];
77
conf.hooks.shellcheck.enable = true;
88
};
99

10+
prek-test = {
11+
expectedHooks = [ "pre-commit" ];
12+
conf = {
13+
package = prek;
14+
hooks.shellcheck.enable = true;
15+
};
16+
};
17+
1018
multiple-hooks-test = {
1119
expectedHooks = [ "commit-msg" "pre-commit" ];
1220
conf.hooks = {

0 commit comments

Comments
 (0)