-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Validation script for git commit message conventions (#355)
* chore: Validation script for git commit message conventions Signed-off-by: Darren Murray <[email protected]>
- Loading branch information
1 parent
cb55505
commit 7fe9678
Showing
3 changed files
with
52 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 |
---|---|---|
|
@@ -98,3 +98,6 @@ endif | |
ifeq (, $(shell which gox)) | ||
go get github.com/mitchellh/gox | ||
endif | ||
|
||
git-env: | ||
scripts/git_env.sh |
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 | ||
# | ||
# Name:: git_env.sh | ||
# Description:: Use this script to configure local git env | ||
# Author:: Darren Murray (<[email protected]>) | ||
# | ||
|
||
readonly commit_hook=scripts/githooks/commit-msg | ||
readonly hooks_path=scripts/githooks/ | ||
readonly project_name=go-sdk | ||
|
||
prepare_git_env(){ | ||
chmod +x $commit_hook | ||
log "Setting git-hooks path to $hooks_path" | ||
git config core.hooksPath $hooks_path | ||
} | ||
|
||
log() { | ||
echo "--> ${project_name}: $1" | ||
} | ||
|
||
prepare_git_env |
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/bash | ||
readonly project_name=go-sdk | ||
readonly commit_tags="feat(:|\(.*\):)|fix(:|\(.*\):)|style(:|\(.*\):)|refactor(:|\(.*\):)\|test(:|\(.*\):)\|docs(:|\(.*\):)\|chore(:|\(.*\):)\|build(:|\(.*\):)\|ci(:|\(.*\):)\|perf(:|\(.*\):)\|metric(:|\(.*\):)\|misc(:|\(.*\):)" | ||
readonly commit_message=`cat $1` | ||
readonly blah="Please enter the commit message for your changes" | ||
|
||
validate_commit_message(){ | ||
if ! [[ $commit_message =~ $commit_tags ]]; then | ||
invalid_message | ||
exit 1 | ||
fi | ||
log "Commit message is valid" | ||
} | ||
|
||
invalid_message(){ | ||
log "Invalid commit message" | ||
log "Message must contain one of feat: | fix: | style: | refactor: | test: | docs: | chore: | build: | ci: | perf: | metric: | misc: | ||
Or with scope in parenthesis eg. feat(cli): Add new feature" | ||
} | ||
|
||
log() { | ||
echo "--> ${project_name}: $1" | ||
} | ||
|
||
validate_commit_message | ||
|