feat: add prek support as pre-commit alternative (#1040)

prek (https://prek.j178.dev) is a faster Rust-based alternative to
pre-commit that uses the same .pre-commit-config.yaml config files.

Changes:
- Add prek detection pattern in hookManagerPatterns (before pre-commit
  to ensure correct detection since prek hooks may contain 'pre-commit')
- Handle prek in checkManagerBdIntegration using same config parser
- Update init_git_hooks.go to recognize prek-installed hooks
- Rename isPreCommit field to isPreCommitFramework for clarity
- Use regex pattern matching all pre-commit/prek signatures consistently
- Add test cases for prek run and prek hook-impl signatures

Co-authored-by: Ismar Iljazovic <ismar@gmail.com>
This commit is contained in:
Ismar
2026-01-13 02:29:57 +01:00
committed by GitHub
parent a8f7c21a74
commit d931f81427
4 changed files with 53 additions and 26 deletions

View File

@@ -586,6 +586,16 @@ func TestDetectActiveHookManager(t *testing.T) {
hookContent: "#!/usr/bin/env bash\n# PRE_COMMIT hook\npre-commit run --all-files\n",
expected: "pre-commit",
},
{
name: "prek run signature",
hookContent: "#!/bin/sh\nprek run pre-commit\n",
expected: "prek",
},
{
name: "prek hook-impl signature",
hookContent: "#!/usr/bin/env bash\nexec prek hook-impl --hook-type=pre-commit\n",
expected: "prek",
},
{
name: "simple-git-hooks signature",
hookContent: "#!/bin/sh\n# simple-git-hooks\nnpm run lint\n",