Last active
August 30, 2018 03:44
-
-
Save DogeVenci/73a188de89bd6de0a49d212ae6e25b64 to your computer and use it in GitHub Desktop.
[git钩子]pre-receive #git #shell #regex
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 | |
echo "--------------push commit msg检查--------------" | |
regex="^\[(CarPlay|8327)\].{10,}" #符合要求格式的正则表达式 | |
while read oldsha newsha refname; do | |
# echo "update : $oldsha,$newsha,$refname" | |
ret=`git log --pretty=format:%s $oldsha..$newsha|awk '$1 !~ /'"$regex"'/ {print $1}'` | |
echo $ret | |
if [ ! -n "$ret" ]; then | |
echo "符合格式要求" | |
exit 0 | |
else | |
echo "不符合格式要求!!!" | |
exit 1 | |
fi | |
done | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment