/ scripts / hooks / commit-msg
commit-msg
 1  #!/usr/bin/env bash
 2  
 3  if [ -z "$1" ]; then
 4    echo "Missing argument (commit message). Did you try to run this manually?"
 5    exit 1
 6  fi
 7  
 8  grep -qE '^(build|ci|chore|deps|docs|feat|fix|hack|style|refactor|perf|test|revert)(\(\w+\))?!?: .+' "$1" || grep -q 'Merge' "$1" || {
 9    echo >&2 '❌ Commit message must be semantic: https://github.com/zeke/semantic-pull-requests' >&2
10    echo >&2 '' >&2
11    echo >&2 'Example: git commit -m "build|ci|chore|docs|feat|fix|hack|style|refactor|perf|test|revert: this is new commit"' >&2
12    exit 1
13  }
14  echo "✅ Commit looks good"