@@ -104,10 +104,10 @@ let
104
104
if [[ ${ toString ( compare cfg . installStages [ "manual" ] ) } -eq 0 ]]
105
105
then
106
106
echo "Running: $ pre-commit run --hook-stage manual --all-files"
107
- pre-commit run -c ${ cfg . configPath } --hook-stage manual --all-files
107
+ ${ lib . getExe cfg . package } run -c ${ cfg . configPath } --hook-stage manual --all-files
108
108
else
109
109
echo "Running: $ pre-commit run --all-files"
110
- pre-commit run -c ${ cfg . configPath } --all-files
110
+ ${ lib . getExe cfg . package } run -c ${ cfg . configPath } --all-files
111
111
fi
112
112
exitcode=$?
113
113
git --no-pager diff --color
144
144
default = true ;
145
145
description = ''
146
146
Whether to enable the pre-commit hooks module.
147
-
147
+
148
148
When set to false, this disables the entire module.
149
149
'' ;
150
150
} ;
155
155
default = true ;
156
156
description = ''
157
157
Whether to enable automatic installation of pre-commit hooks.
158
-
158
+
159
159
When set to false, hooks will not be installed into the git repository,
160
160
but all other module functionality (like configuration generation) will still work.
161
161
'' ;
441
441
442
442
installationScript =
443
443
''
444
- export PATH=${ cfg . package } /bin:$PATH
445
444
if ${ boolToString cfg . install . enable } ; then
446
445
if ! ${ cfg . gitPackage } /bin/git rev-parse --git-dir &> /dev/null; then
447
446
echo 1>&2 "WARNING: git-hooks.nix: .git not found; skipping installation."
448
447
else
449
- GIT_WC=`${ cfg . gitPackage } /bin/git rev-parse --show-toplevel`
448
+ GIT_WC=`${ lib . getExe cfg . gitPackage } rev-parse --show-toplevel`
450
449
451
450
# These update procedures compare before they write, to avoid
452
451
# filesystem churn. This improves performance with watch tools like lorri
474
473
# Remove any previously installed hooks (since pre-commit itself has no convergent design)
475
474
hooks="${ concatStringsSep " " ( remove "manual" supportedHooksLib . supportedHooks ) } "
476
475
for hook in $hooks; do
477
- pre-commit uninstall -t $hook
476
+ ${ lib . getExe cfg . package } uninstall -t $hook
478
477
done
479
- ${ cfg . gitPackage } /bin/git config --local core.hooksPath ""
478
+ ${ lib . getExe cfg . gitPackage } config --local core.hooksPath ""
480
479
# Add hooks for configured stages (only) ...
481
480
if [ ! -z "${ concatStringsSep " " install_stages } " ]; then
482
481
for stage in ${ concatStringsSep " " install_stages } ; do
486
485
# if you amend these switches please also review $hooks above
487
486
commit | merge-commit | push)
488
487
stage="pre-"$stage
489
- pre-commit install -c ${ cfg . configPath } -t $stage
488
+ ${ lib . getExe cfg . package } install -c ${ cfg . configPath } -t $stage
490
489
;;
491
490
${ concatStringsSep "|" supportedHooksLib . supportedHooks } )
492
- pre-commit install -c ${ cfg . configPath } -t $stage
491
+ ${ lib . getExe cfg . package } install -c ${ cfg . configPath } -t $stage
493
492
;;
494
493
*)
495
494
echo 1>&2 "ERROR: git-hooks.nix: either $stage is not a valid stage or git-hooks.nix doesn't yet support it."
499
498
done
500
499
# ... or default 'pre-commit' hook
501
500
else
502
- pre-commit install -c ${ cfg . configPath }
501
+ ${ lib . getExe cfg . package } install -c ${ cfg . configPath }
503
502
fi
504
503
505
504
# Fetch the absolute path to the git common directory. This will normally point to $GIT_WC/.git.
508
507
# Convert the absolute path to a path relative to the toplevel working directory.
509
508
common_dir='' ${common_dir#'' $GIT_WC/}
510
509
511
- ${ cfg . gitPackage } /bin/git config --local core.hooksPath "'' $common_dir/hooks"
510
+ ${ lib . getExe cfg . gitPackage } config --local core.hooksPath "'' $common_dir/hooks"
512
511
fi
513
512
fi
514
513
fi
0 commit comments