Skip to content

Commit

Permalink
Merge pull request #59 from sasjs/git-hooks
Browse files Browse the repository at this point in the history
feat(git): enabled git hook enforcing conventional commits
  • Loading branch information
YuryShkoda authored May 20, 2021
2 parents 0f2fe7c + 08b9751 commit 7489442
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .git-hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
RED="\033[1;31m"
GREEN="\033[1;32m"

# Get the commit message (the parameter we're given is just the path to the
# temporary file which holds the message).
commit_message=$(cat "$1")

if (echo "$commit_message" | grep -Eq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z \-]+\))?!?: .+$") then
echo "${GREEN} ✔ Commit message meets Conventional Commit standards"
exit 0
fi

echo "${RED}❌ Commit message does not meet the Conventional Commit standard!"
echo "An example of a valid message is:"
echo " feat(login): add the 'remember me' button"
echo "ℹ More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary"
exit 1
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"semantic-release": "semantic-release -d",
"package:lib": "vsce package"
"package:lib": "vsce package",
"postinstall": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true"
},
"devDependencies": {
"@types/glob": "^7.1.3",
Expand Down

0 comments on commit 7489442

Please sign in to comment.