mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-08-06 04:21:33 +00:00
86a2021c92
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)
33 lines
905 B
Bash
Executable File
33 lines
905 B
Bash
Executable File
#!/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
|