-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Very basic commit message validation for semantic-release
- Loading branch information
1 parent
fb7a144
commit 0b6e40b
Showing
4 changed files
with
32 additions
and
1 deletion.
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 @@ | ||
_ |
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,23 @@ | ||
#!/bin/bash | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
# Ideally, we might want to use a package like commitizen or commitlint, | ||
# but as far as I can tell, those don't work with GUI git clients like GitKraken. | ||
# And they are actually overkill for what we need here (though we could custom configure them). | ||
|
||
# Read the commit message from the file passed as an argument | ||
COMMIT_MSG=$(cat "$1") | ||
|
||
# Check if the commit message contains a colon. | ||
# This is a super basic validation and could certainly be improved. | ||
if ! echo "$COMMIT_MSG" | grep -q ":"; then | ||
echo "Improper commit message for semantic-release." | ||
echo "Please use the format 'type: message'" | ||
echo "e.g. chore: Updated README" | ||
echo "e.g. fix: Made a repair" | ||
echo "e.g. feat: Added a new thing" | ||
exit 1 | ||
fi | ||
|
||
# If we reach here, the commit message is valid | ||
exit 0 |
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
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