allow temporarily disabling pre-commit hooks

This commit is contained in:
2024-07-28 01:13:04 -04:00
committed by Alice Huston
parent 885a9b0381
commit bfeb50e44f
3 changed files with 18 additions and 1 deletions

View File

@ -13,7 +13,18 @@ forEachSystem (
# construct the shell provided by pre-commit for running hooks
pre-commit = pkgs.mkShell {
inherit (checks.${system}.pre-commit-check) shellHook;
shellHook = ''
if [ -f ./.noprecommit ]; then
echo ".noprecommit found! Delete this file to re-install pre-commit hooks"
if [ -f ./.pre-commit-config.yaml ]; then
echo "uninstalling pre-commit hooks"
pre-commit uninstall
rm .pre-commit-config.yaml
fi
else
${checks.${system}.pre-commit-check.shellHook}
fi
'';
buildInputs = checks.${system}.pre-commit-check.enabledPackages;
};