Created
September 25, 2017 12:31
-
-
Save silverweed/768e50c681604862bfdba0d0ca059390 to your computer and use it in GitHub Desktop.
Git hook that warns when there are lines longer than 120 characters
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/bash | |
HARDLIMIT=120 | |
FOUND=$(find src/ -not -path \*third\* -type f -name \*pp -exec awk -v HL=$HARDLIMIT ' | |
length($0) > HL { | |
printf "%s:%d %s", FILENAME, FNR, $0 | |
}' {} +) | |
if [[ -n $FOUND ]]; then | |
echo "Following lines are longer than hardlimit $HARDLIMIT:" | |
while read LINE; do echo $LINE; done < <(echo -e $FOUND) | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment