#!/bin/sh # # This is an example Git hook for use with Rush. To enable this hook, rename this file # to "commit-msg" and then run "rush install", which will copy it from common/git-hooks # to the .git/hooks folder. # # TO LEARN MORE ABOUT GIT HOOKS # # The Git documentation is here: https://git-scm.com/docs/githooks # Some helpful resources: https://githooks.com # # ABOUT THIS EXAMPLE # # The commit-msg hook is called by "git commit" with one argument, the name of the file # that has the commit message. The hook should exit with non-zero status after issuing # an appropriate message if it wants to stop the commit. The hook is allowed to edit # the commit message file. # enforce conventional commits # INPUT_FILE=$1 # START_LINE=`head -n1 $INPUT_FILE` # PATTERN="^(BREAKING CHANGE)|(feat)|(fix)|(build)|(chore)|(ci)|(docs)|(style)|(refactor)|(perf)|(test)(\(\w+\))?!?: .+" # if ! [[ "$START_LINE" =~ $PATTERN ]]; then # echo "Bad commit message, see example conventional commits: https://www.conventionalcommits.org/en/v1.0.0/" # exit 1 # fi INPUT_FILE=$1 node common/scripts/install-run-rush.js commitlint --edit "$INPUT_FILE"