dotfiles

My PC Dotfiles & Website

files/git/hooks/commit-msg (438B)


 1#!/usr/bin/env bash
 2error() { echo -e "\033[0;31merror:\033[0m $1"; exit 7; }
 3
 4## Commit Message ##
 5
 6# 1. Structure
 7if ! head -n 1 "$1" | grep -qE '^(feat|fix|ci|blog|chore|docs|test|style|refactor)(\([^)]+\))?!?: .+$'
 8then
 9  error "Commit Message header is invalid\nFormat -> type(scope): subject"
10fi
11
12# 2. Length
13if ! head -n 1 "$1" | grep -qE '^.{1,50}$'
14then
15  error "Commit Message header is too long\nGreater than 50 characters"
16fi