-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
14 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 |
---|---|---|
@@ -1,23 +1,53 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
echo "π¨ Checking commit message..." | ||
echo "Checking commit message..." | ||
message="$(cat $1)" | ||
requiredPattern="^(add|cut|fix|bump|make|start|stop|refactor|reformat|optimise|document|merge|configured) .*$" | ||
if ! [[ $message =~ $requiredPattern ]]; | ||
then | ||
echo "-" | ||
echo "-" | ||
echo "-" | ||
|
||
#requiredPattern="^(add|cut|fix|bump|make|start|stop|refactor|reformat|optimise|document|merge|configured) .*$" | ||
#if ! [[ $message =~ $requiredPattern ]]; | ||
#then | ||
# echo "-" | ||
# echo "-" | ||
# echo "-" | ||
# echo "π¨ Wrong commit message! π" | ||
# echo "The commit message must have this format:" | ||
# echo "<verb in imperative mood> <what was done>" | ||
# echo "Allowed verbs in imperative mood: add, cut, fix, bump, make, start, stop, refactor, reformat, optimise, document, merge" | ||
# echo "Example: add login button" | ||
# echo "-" | ||
# echo "Your commit message was:" | ||
# echo $message | ||
# echo "-" | ||
# echo "For more information, check script in .husky/commit-msg" | ||
# echo "-" | ||
# exit 1 | ||
#fi | ||
|
||
|
||
# Check if the string has at least 9 characters | ||
if [ ${#message} -lt 9 ]; then | ||
echo "π¨ Wrong commit message! π" | ||
echo "The commit message must have this format:" | ||
echo "<verb in imperative mood> <what was done>" | ||
echo "Allowed verbs in imperative mood: add, cut, fix, bump, make, start, stop, refactor, reformat, optimise, document, merge" | ||
echo "Example: add login button" | ||
echo "-" | ||
echo "Error: Commit message should have at least 9 characters." | ||
echo "Your commit message was:" | ||
echo $message | ||
echo "-" | ||
echo "For more information, check script in .husky/commit-msg" | ||
exit 1 | ||
fi | ||
|
||
# Check if the string contains 2 words | ||
wordCount=$(echo "$message" | wc -w) | ||
echo "wordCount: $wordCount" | ||
if [ $wordCount -lt 2 ]; then | ||
echo "π¨ Wrong commit message! π" | ||
echo "Error: Commit message should contain at least 2 words." | ||
echo "Your commit message was:" | ||
echo $message | ||
echo "-" | ||
echo "For more information, check script in .husky/commit-msg" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "β Commit message is valid!" | ||
|
||
echo "β commit-msg hook finished successfully" |
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