Skip to content

Commit 00e7be7

Browse files
authored
Clarify why check-illegal-windows-names stays builtin-only (#1857)
1 parent 1dbec0c commit 00e7be7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

crates/prek/src/hooks/builtin_hooks/check_illegal_windows_names.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ use crate::hook::Hook;
44

55
pub(super) const ILLEGAL_WINDOWS_PATTERN: &str = r"(?i)((^|/)(CON|PRN|AUX|NUL|COM[\d\x{00B9}\x{00B2}\x{00B3}]|LPT[\d\x{00B9}\x{00B2}\x{00B3}])(\.|/|$)|[<>:\x22\\|?*\x00-\x1F]|/[^/]*[\.\s]/|[^/]*[\.\s]$)";
66

7+
// Keep this hook in `builtin_hooks` instead of `pre_commit_hooks`.
8+
//
9+
// Upstream implements `check-illegal-windows-names` as a `fail` hook with a
10+
// `files` regex. Our pre-commit-hooks fast path already handles that generic
11+
// `fail` language in Rust, so there is no dedicated fast-path implementation to
12+
// add here. This module only exists to provide the builtin-hook equivalent:
13+
// reuse the same regex for matching, then emit a simple fail-style message.
714
pub(crate) fn check_illegal_windows_names(_hook: &Hook, filenames: &[&Path]) -> (i32, Vec<u8>) {
815
if filenames.is_empty() {
916
return (0, Vec::new());
1017
}
1118

12-
// Matching is handled by the hook's `files` pattern. Any filename that reaches this
13-
// builtin is already known to be invalid, so we only need to emit fail-style errors.
1419
let mut output = Vec::new();
1520
for filename in filenames {
1621
output.extend_from_slice(

0 commit comments

Comments
 (0)