forked from cloudfoundry/pcap-release
-
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.
ci(test): local conventional commit check
Co-authored-by: Soha Alboghdady <[email protected]>
- Loading branch information
1 parent
a63b124
commit afc67fa
Showing
2 changed files
with
33 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,17 @@ | ||
# Git Hooks | ||
|
||
Run conventional commit checks locally without any tool installation | ||
|
||
## Usage | ||
|
||
Execute the below command in the root directory of the project: | ||
|
||
```sh | ||
ln -s -f ../../.hooks/commit-msg ./.git/hooks/commit-msg | ||
``` | ||
|
||
Make the file executable: | ||
|
||
```sh | ||
chmod +x ./.hooks/commit-msg | ||
``` |
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,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
first_line=$(head -n1 "$1") | ||
echo "commit message: $first_line" | ||
|
||
conv_commit_msg="^(fix|feat|build|chore|ci|docs|style|refactor|perf|test)(\(.{1,50}\))?: (.{1,100})\$" | ||
flag=0 | ||
if ! [[ "$first_line" =~ (${conv_commit_msg}) ]]; then | ||
flag=1 | ||
echo "ERROR: Conventional commit message formatting error" >&2 | ||
echo "$first_line" >&2 | ||
fi | ||
|
||
if [ "$flag" -ne 0 ]; then | ||
exit 1 | ||
fi |