-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/VIH-5605 : added pre commit message hook
- Loading branch information
1 parent
7cae164
commit 96fd07d
Showing
3 changed files
with
37 additions
and
3 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,29 @@ | ||
#!/bin/sh | ||
|
||
COMMIT_MSG_FILE=$1 | ||
COMMIT_SOURCE=$2 | ||
SHA1=$3 | ||
|
||
|
||
# Get the current branch name | ||
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | ||
# exstract a part of branch name with the VIH-XXX | ||
TRIMMED=$(echo $BRANCH_NAME | sed -e 's/.*\/*\(VIH-[0-9]\{4\}\).*/\1/') | ||
# get the current commit message | ||
currentmsg=$(cat "$COMMIT_MSG_FILE") | ||
message="Commit message must start with the prefix 'feature/VIH-XXXX : ' folowing by 8 or more characters. Your commit will be rejected. You should rename your commit to a valid name and try again." | ||
valid_mesg_regex="^(feature\/VIH-[0-9]{4} : )([:_, a-zA-Z0-9.-]{8,})+$" | ||
|
||
feature="feature/" | ||
|
||
if [[ ! $currentmsg =~ $valid_mesg_regex ]] | ||
then | ||
echo "$message" | ||
exit 1 | ||
fi | ||
exit 0 | ||
fi | ||
|
||
|
||
|
||
|
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