Created
January 23, 2023 04:29
-
-
Save travisjungroth/325787d62fb3fb80358b9160bd97a026 to your computer and use it in GitHub Desktop.
Run the pre-commit tool and commit any changes. Save to .git/hooks/post-commit or add as a line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
messages=$(git log --format=%s -3) | |
repeated="autocommit | |
autocommit | |
autocommit" | |
if [ "$messages" = "$repeated" ]; then | |
echo "3 times, enough already." | |
exit 1 | |
fi | |
changed=$(git diff --name-only HEAD HEAD^) | |
pre-commit run --files $changed | |
git add $changed | |
if ! git diff --cached --quiet ; then | |
git commit -m "autocommit" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment