Skip to content

Instantly share code, notes, and snippets.

@DogeVenci
Last active August 30, 2018 03:44
Show Gist options
  • Save DogeVenci/73a188de89bd6de0a49d212ae6e25b64 to your computer and use it in GitHub Desktop.
Save DogeVenci/73a188de89bd6de0a49d212ae6e25b64 to your computer and use it in GitHub Desktop.
[git钩子]pre-receive #git #shell #regex
#!/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