iuna

iuna

iuna - experimental mainnet-candidate protocol
git clone https://getiuna.org/git/iuna.git
Log | Files | Refs | README | LICENSE

check-commit-title.sh (751B)


      1 #!/usr/bin/env bash
      2 set -euo pipefail
      3 
      4 usage() {
      5   echo "Usage: $0 <commit-message-file>" >&2
      6   echo "       $0 --title <commit-title>" >&2
      7   exit 2
      8 }
      9 
     10 case "$#:${1:-}" in
     11   1:*)
     12     [ -f "$1" ] || usage
     13     IFS= read -r title < "$1" || true
     14     ;;
     15   2:--title)
     16     title="$2"
     17     ;;
     18   *)
     19     usage
     20     ;;
     21 esac
     22 
     23 pattern='^(feat|fix|docs|refactor|perf|test|build|ci|chore|revert)(\([a-z0-9][a-z0-9._/-]*\))?!?: .+'
     24 
     25 if [[ ! "$title" =~ $pattern ]]; then
     26   cat >&2 <<EOF
     27 Invalid commit title:
     28   ${title}
     29 
     30 Use a Conventional Commit prefix:
     31   feat, fix, docs, refactor, perf, test, build, ci, chore, or revert
     32 
     33 Examples:
     34   feat(wallet): add transaction filters
     35   fix!: reject incompatible database formats
     36   chore(release): release v0.5.0
     37 EOF
     38   exit 1
     39 fi