feat: add commit-msg hook, improve robustness

- Add commit-msg hook enforcing Conventional Commits format
  (allows merge, fixup, and squash commits)
- Fix file size display: use MiB (binary) to match the binary limit calculation
- Make gitleaks optional: skip gracefully if not installed
- Suppress stderr on mg register in pre-push
- Add shellcheck directive to pre-commit
- Mark gitleaks as optional in README prerequisites
- Clean up FUNDING.yml boilerplate
This commit is contained in:
2026-03-09 06:31:38 +00:00
parent 7dbcec889d
commit 33fd98d746
5 changed files with 68 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2086
set +eou pipefail
size_limit=$((5 * 2**20))
@@ -27,7 +28,7 @@ for file in $(git diff-index --cached --name-only "$against"); do
fi
file_size=$(stat --format='%s' "$file" 2>/dev/null || stat -f '%z' "$file" 2>/dev/null || echo 0)
if [ "$file_size" -gt "$size_limit" ]; then
echo "File $file is $((file_size / 10**6))MB, which is larger than our configured limit of $((size_limit / 10**6))MB"
echo "File $file is $((file_size / 2**20))MiB, which is larger than our configured limit of $((size_limit / 2**20))MiB"
hasLargeFile=true
fi
done
@@ -39,4 +40,7 @@ if $hasLargeFile; then
fi
popd > /dev/null 2>&1 || true
gitleaks protect --staged --verbose --no-banner --no-color 2>/dev/null
if command -v gitleaks > /dev/null 2>&1; then
gitleaks protect --staged --verbose --no-banner --no-color 2>/dev/null
fi