mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-08-05 20:11:31 +00:00
chore(githooks): Add pre-commit hook allowing two staged paths
Ship a tracked hook that rejects more than two staged paths so commits stay small while still allowing tightly coupled pairs. - Activate with: git config core.hooksPath .githooks (from repo root)
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Pre-commit hook: prefer small commits; allow at most two staged paths.
|
||||
# Enable with: git config core.hooksPath .githooks
|
||||
|
||||
staged_files=$(git diff --cached --name-only)
|
||||
file_count=$(echo "$staged_files" | grep -v '^$' | wc -l | tr -d ' ')
|
||||
|
||||
if [ "$file_count" -gt 2 ]; then
|
||||
echo "❌ COMMIT PROTOCOL VIOLATION: Attempting to commit $file_count files (maximum 2)"
|
||||
echo ""
|
||||
echo "Prefer tiny commits; combining more than two paths needs splitting or a hook bypass."
|
||||
echo ""
|
||||
echo "Staged files:"
|
||||
echo "$staged_files"
|
||||
echo ""
|
||||
echo "See .github/prompts/commit.prompt.md"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$file_count" -eq 2 ]; then
|
||||
echo "✅ Committing two files:"
|
||||
echo "$staged_files"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$file_count" -eq 1 ]; then
|
||||
echo "✅ Committing single file: $(echo "$staged_files" | head -1)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "⚠️ No files staged for commit"
|
||||
exit 1
|
||||
Reference in New Issue
Block a user