allow temporarily disabling pre-commit hooks

This commit is contained in:
ahuston-0 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

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# direnv
.direnv
.envrc
.noprecommit
# build outputs
.*.swp

View File

@ -14,6 +14,11 @@ Please install `direnv` and run `direnv allow` in the project directory to
add the pre-commit-hooks to your workflow. We will reject PRs if we notice
violations in the pre-commit checks.
To disable pre-commit hooks from your shell, run `touch .noprecommit` in the
top-level of the repo. This will not stop the checks from running during the PR
checks, but will prevent them from running in the direnv environment when
inconvenient.
## Active Development
To contribute to the repo, you can either ask to have a role (for those who are

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;
};