Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ repos:
always_run: true
pass_filenames: false
language: system
# Case-only renames break macOS (case-insensitive) checkouts when casing
# drifts between branches. Existing check-case-conflict only catches two
# distinct paths that collide when lowercased, not a single-file rename.
- id: prevent-case-only-rename
name: prevent case-only renames
entry: bash tools/prevent_case_only_rename.sh
always_run: true
pass_filenames: false
language: system

# Javascript linting, formatting.
# We're using the local node_modules to simplify things, otherwise would
Expand Down
13 changes: 13 additions & 0 deletions tools/prevent_case_only_rename.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Reject staged case-only renames (Foo.tsx -> foo.tsx).
# These break macOS case-insensitive checkouts when casing drifts across branches.
# check-case-conflict only catches two distinct paths that collide when lowercased.
set -euo pipefail

git diff --cached -M --name-status | awk -F '\t' '
$1 ~ /^R/ && tolower($2) == tolower($3) && $2 != $3 {
print "case-only rename forbidden:", $2, "->", $3
err = 1
}
END { exit err + 0 }
'
Loading