-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add githook for commit messages
- Loading branch information
1 parent
f125420
commit ac663aa
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Create a regex for a conventional commit. | ||
convetional_commit_regex="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-z \-]+\))?!?: .+$" | ||
|
||
# Get the commit message (the parameter we're given is just the path to the | ||
# temporary file which holds the message). | ||
commit_message=$(cat "$1") | ||
|
||
# Check the message, if we match, all good baby. | ||
if [[ "$commit_message" =~ $convetional_commit_regex ]]; then | ||
echo -e "\e[32mCommit message meets Conventional Commit standards...\e[0m" | ||
exit 0 | ||
fi | ||
|
||
# Uh-oh, this is not a conventional commit, show an example and link to the spec. | ||
echo -e "\e[31mThe commit message does not meet the Conventional Commit standard\e[0m" | ||
echo "An example of a valid message is: " | ||
echo " feat(login): add the 'remember me' button" | ||
echo "More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary" | ||
exit 1 | ||
|
||
|
||
|