Created
July 10, 2016 21:34
-
-
Save DannyDelott/c0fa3b89f3e930a335ddd402d7b13ee6 to your computer and use it in GitHub Desktop.
pre-push
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 | |
red=$'\e[1;31m' | |
grn=$'\e[1;32m' | |
yel=$'\e[1;33m' | |
blu=$'\e[1;34m' | |
mag=$'\e[1;35m' | |
cyn=$'\e[1;36m' | |
end=$'\e[0m' | |
exit_code=0 | |
while read -r line; do | |
if [[ ! "$line" =~ ^\[(FE|BE|DOCS|BUILD)\] ]] | |
then | |
# Parse commit and hash into list | |
IFS="::" read -r -a tuple <<< "$line" | |
if [[ $exit_code == 0 ]]; then | |
printf "\n%sMissing commit message label:%s\n\n" "$red" "$end" | |
fi | |
printf "\t%s\t\t%s\n" "${tuple[2]}" "${tuple[0]}" | |
exit_code=1 | |
fi | |
done <<< "$(git log origin/master..HEAD --pretty=format:'%s::%h')" | |
printf "\n" | |
exit $exit_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment