#!/bin/sh #echo Checking git message in $1 usage="\n Please see the guidelines for git commit messages in the CONTRIBUTORS file\n Your git commit message should start with a line of the form\n \n HPCC-XXXX Short description\n \n where XXXX is the Jira issue number that this commit is referencing, and\n short description is a brief description of the issue that will appear in\n the --oneline version of the generated changelog.\n \n Use git commit -s -t $1 to reopen previous message for editing\n" (head -1 "$1" | grep -E -q "^HPCC-[0-9]+ |^Merge ") || { echo >&2 "\n ERROR: Missing Jira issue on beginning of first line (HPCC-XXXX)" echo >&2 $usage exit 1 } (head -1 "$1" | grep -E -q "[^.]$") || { echo >&2 "\n ERROR: Please don't use . at the end of the short description" echo >&2 $usage exit 1 } (head -1 "$1" | grep -E -q "^HPCC-[0-9]+ [^a-z]|^Merge ") || { echo >&2 "\n ERROR: Short description should start with a capital" echo >&2 $usage exit 1 } (head -2 "$1" | tail -1 | grep -E -q "^$") || { echo >&2 "\n ERROR: Short description must be followed by a blank line. Have you signed your commit?" echo >&2 $usage exit 1 } [ $(grep -v '^#' "$1" | wc -L ) -le 80 ] || { echo >&2 "\n ERROR: Commit message lines too long (max 80 chars)." echo >&2 $usage exit 1 } (grep -q "^Signed-off-by: " "$1") || { echo >&2 "\n ERROR: Commit not signed. All commits should be signed (use git commit -s)." echo >&2 $usage exit 1 }