Skip to content

Commit

Permalink
pre-commit: test meta hooks
Browse files Browse the repository at this point in the history
Closes NixOS#270805 by verifying that NixOS#251418 fixes the issue.
  • Loading branch information
l0b0 committed Oct 10, 2024
1 parent ed61c2e commit fc7cf6f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkgs/tools/misc/pre-commit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ buildPythonApplication rec {
"pre_commit"
];

passthru.tests.version = testers.testVersion {
package = pre-commit;
passthru.tests = callPackage ./tests.nix {
inherit git pre-commit;
};

meta = with lib; {
Expand Down
45 changes: 45 additions & 0 deletions pkgs/tools/misc/pre-commit/tests.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
git,
pre-commit,
runCommand,
testers,
}:
{
check-meta-hooks =
runCommand "check-meta-hooks"
{
nativeBuildInputs = [
git
pre-commit
];
}
''
cd "$(mktemp --directory)"
export HOME="$PWD"
cat << 'EOF' > .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: echo
name: echo
entry: echo
files: \.yaml$
language: system
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- id: identity
EOF
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init --initial-branch=main
git add .
pre-commit run --all-files
touch $out
'';

version = testers.testVersion {
package = pre-commit;
};
}

0 comments on commit fc7cf6f

Please sign in to comment.