mirror of
https://github.com/j178/prek.git
synced 2026-04-25 02:11:36 +02:00
cb3f71c322
## Summary Add a native Rust fast path for the `check-vcs-permalinks` hook from `pre-commit/pre-commit-hooks`. ## Why this matters Without a fast path, prek must clone the `pre-commit/pre-commit-hooks` repo, install Python, and run the hook script. The native implementation avoids that overhead for a simple regex-based check. ## Changes - New file: `crates/prek/src/hooks/pre_commit_hooks/check_vcs_permalinks.rs` - Port of the [upstream Python implementation](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/check_vcs_permalinks.py) - Detects GitHub blob URLs that use a branch name (e.g. `main`, `master`) instead of a commit hash, combined with a `#L` line number anchor - Scans files concurrently using the existing `run_concurrent_file_checks` helper - Reports file path, line number, and offending line content - Includes unit tests for permalinks, branch links, and edge cases - Updated `crates/prek/src/hooks/pre_commit_hooks/mod.rs`: added `CheckVcsPermalinks` variant ## Testing - `cargo check -p prek` passes - Unit tests verify both positive (branch link) and negative (commit hash permalink) cases Fixes #1833 This contribution was developed with AI assistance (Claude Code). --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Jo <10510431+j178@users.noreply.github.com>