Last active
February 21, 2024 15:06
-
-
Save arnaduga/f006c51e72a322bcff5e7b622d35d3da to your computer and use it in GitHub Desktop.
Setting up a commit message check
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
#!/bin/bash | |
cat $1 | grep -w "test\\|refactor\\|feat\\|fix\\|docs\\|breaking-change\\|chore\\|build" > /dev/null | |
if \[ $? -eq 0 \]; then | |
echo "✔️ Commit message CHECKED: good." | |
else | |
echo "❌ !!WARNING!! Commit message MUST start with test,refactor, fix, feat, docs, breaking-change, chore or build" | |
echo "❌ COMMIT ABORDED !!!" | |
exit 1 | |
fi |
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
# Back to your hom | |
$ cd | |
# Create appropriate folder | |
$ mkdir ~/.git-templates/hooks | |
# Create the hook file | |
$ touch commit-msg | |
### Here, edit the created file and add the "commit-msg" content (GIST) | |
# Make the file executable | |
$ chmod a+x ~/.git-templates/hooks/commit-msg | |
# Set up you git config | |
$ git config --global init.templatedir '~/.git-templates' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment