githooks

Personal git hooks
git clone git://pollux.codes/git/githooks.git
Log | Files | Refs | README

commit-msg (407B)


      1 #!/bin/sh
      2 
      3 # Check commit header
      4 REGEX="^(feat|fix|docs|chore|style|wip)(\([a-z \-]+\))?!?: .{1,50}$"
      5 cat "$1" | head -n1 | grep -E "$REGEX" > /dev/null
      6 
      7 if [ $? -gt 0 ]; then
      8 	echo "Improper commit header"
      9 	exit 1
     10 fi
     11 
     12 # Check for signed-off-by footer
     13 cat "$1" | grep "^[^#]" | tail -n1 | grep -E "^Signed-off-by: " > /dev/null
     14 
     15 if [ $? -gt 0 ]; then
     16 	echo "Missing Signed-off-by footer"
     17 	exit 1
     18 fi
     19 
     20 exit 0