diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index cbb172c..2a38e55 100755 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -5,27 +5,8 @@ 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") -choretxt=${commit_message:1-15} -echo choretxt=$choretxt -# abort processing if this is a changelog release commit -if [[ "$choretxt" = "chore(release):" ]]; then - echo "${GREEN} ✔ Changelog release" - exit 0 -fi - -# abort processing if there are linting errors -sasjs lint - -# Prevent accidential commits to the master branch -BRANCH=`git rev-parse --abbrev-ref HEAD` -if [[ "$BRANCH" =~ ^(master|main|develop)$ ]]; then - echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?" - echo "If so, commit with -n to bypass the pre-commit hook." - exit 1 -fi - -# Finally, check the commit message for any obvious mistakes. +# Check the commit message for any obvious mistakes. if (echo "$commit_message" | grep -Eq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9 \-]+\))?!?: .+$") then echo "${GREEN} ✔ Commit message meets Conventional Commit standards" exit 0 @@ -36,3 +17,4 @@ 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 +