Files
dc/.git-hooks/pre-commit

23 lines
792 B
Plaintext
Raw Normal View History

2023-07-13 13:44:05 +02:00
#!/bin/sh
2025-06-11 13:11:30 +02:00
# Using `--silent` helps for showing any errs in the first line of the response
# The first line is picked up by the VS Code GIT UI popup when rc is not 0
2023-07-13 13:44:05 +02:00
if npm run --silent lint:check:silent ; then
2025-06-11 13:11:30 +02:00
exit 0
else
npm run --silent lint:fix:silent
2025-06-11 13:11:30 +02:00
echo "❌ Prettier check failed! We ran lint:fix for you. Please add & commit again."
exit 1
2023-07-13 13:44:05 +02:00
fi
## Avoid large commits
# https://www.backblaze.com/blog/how-many-bytes-are-in-a-megabyte-really/
size_limit=$((2 * 2**20)) # 2mbs
# https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---disk-usage
commit_size=$(git rev-list --disk-usage HEAD^..HEAD)
test "$commit_size" -lt "$size_limit" || (
echo "Commit size is too large: $commit_size > $size_limit"
echo "Force commit using --no-verify"
exit 1
)