-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: pre commit semantic commit msg check (#659)
- Loading branch information
1 parent
701f453
commit 75e5c6c
Showing
2 changed files
with
38 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
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,28 @@ | ||
#!/bin/sh | ||
|
||
if [ -z "$1" ]; then | ||
echo "Missing argument (commit message). Did you try to run this manually?" | ||
exit 1 | ||
fi | ||
|
||
commitTitle="$(cat $1 | head -n1)" | ||
|
||
# ignore merge requests | ||
if echo "$commitTitle" | grep -qE "Merge branch"; then | ||
echo "Commit hook: ignoring branch merge" | ||
exit 0 | ||
fi | ||
# check semantic versioning scheme | ||
if ! echo "$commitTitle" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(\([a-z0-9\s\-\_\,]+\))?!?:\s\w'; then | ||
echo "Your commit message did not follow semantic versioning: $commitTitle" | ||
echo "" | ||
echo "Format: <type>(<optional-scope>): <subject>" | ||
echo "Example: feat(deriv-auth): single entry" | ||
echo "" | ||
echo "Valid types: build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test" | ||
echo "" | ||
echo "Please see" | ||
echo "- https://github.com/regentmarkets/flutter-deriv-packages/blob/master/.github/GIT_RULES.md" | ||
echo "- https://www.conventionalcommits.org/en/v1.0.0/#summary" | ||
exit 1 | ||
fi |