summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/pr/pre-commit/tests.nix
blob: 309374bbf31104ff40e11cb9beeb53b31e602c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
  gitMinimal,
  pre-commit,
  runCommand,
}:
{
  check-meta-hooks =
    runCommand "check-meta-hooks"
      {
        nativeBuildInputs = [
          gitMinimal
          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 "you@example.com"
        git config --global user.name "Your Name"
        git init --initial-branch=main
        git add .
        pre-commit run --all-files
        touch $out
      '';
}