Created
June 7, 2012 13:28
-
-
Save keithamus/2888810 to your computer and use it in GitHub Desktop.
Tim Pope's Commit Message format - BDFL version. http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
message=`sed '/^#/,$d' $1` | |
firstLine=`echo "$message" | awk 'NR>1{exit};1'` | |
exitCode=0 | |
txtred=$(tput setaf 1) # Red | |
txtrst=$(tput sgr0) # Text reset | |
if [[ "`echo "$firstLine" | awk '{print length()}'`" -gt 49 ]]; then | |
echo "${txtred}[POLICY] Ensure first line in your commit message is no longer than 50 characters${txtrst}" | |
exitCode=1 | |
fi | |
if [[ "`echo "$message" | awk ' { if ( length > x ) { x = length } }END{ print x }'`" -gt "71" ]]; then | |
echo "${txtred}[POLICY] Ensure no lines in your commit message are no longer than 72 chars${txtrst}" | |
exitCode=1 | |
fi | |
if [[ "$exitCode" -gt "0" ]]; then | |
echo "Your commit message was:\n" | |
echo "$message" | awk '{ print " " $0 }' | |
echo "" | |
fi | |
exit $exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment