dotfiles

My PC Dotfiles & Website

commit-msg (438B)


#!/usr/bin/env bash
error() { echo -e "\033[0;31merror:\033[0m $1"; exit 7; }

## Commit Message ##

# 1. Structure
if ! head -n 1 "$1" | grep -qE '^(feat|fix|ci|blog|chore|docs|test|style|refactor)(\([^)]+\))?!?: .+$'
then
  error "Commit Message header is invalid\nFormat -> type(scope): subject"
fi

# 2. Length
if ! head -n 1 "$1" | grep -qE '^.{1,50}$'
then
  error "Commit Message header is too long\nGreater than 50 characters"
fi