-
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.
chore: Add pre-commit hooks with config instructions
Signed-off-by: Sietze van Buuren <s.van.buuren@gmail.com>
- Loading branch information
1 parent
e01c6eb
commit 78d3e10
Showing
2 changed files
with
35 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,26 @@ | ||
#!/bin/sh | ||
# | ||
# A hook script to check that the commit message follows Angular style. | ||
|
||
# Regex to match Angular commit message style (validating only the first line) | ||
COMMIT_MSG_REGEX="^(feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(\w+\))?: .{1,50}" | ||
|
||
# Read only the first line of the commit message | ||
FIRST_LINE=$(head -n 1 "$1") | ||
|
||
# Validate the first line | ||
if ! echo "$FIRST_LINE" | grep -qE "$COMMIT_MSG_REGEX"; then | ||
echo >&2 "ERROR: Commit message does not follow Angular style." | ||
echo >&2 "" | ||
echo >&2 "The first line must follow the format: <type>(<scope>): <short description>" | ||
echo >&2 "" | ||
echo >&2 "Examples:" | ||
echo >&2 " feat(core): add new feature" | ||
echo >&2 " fix(parser): handle edge case" | ||
echo >&2 " docs(readme): update project overview" | ||
echo >&2 "" | ||
exit 1 | ||
fi | ||
|
||
# If the first line is valid, allow the commit | ||
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