Created
May 17, 2017 09:36
-
-
Save vglebov/b365da8d0b3eec01338a52087cece3f3 to your computer and use it in GitHub Desktop.
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 | |
set -e | |
#set -x | |
Main (){ | |
Allow "commiter1@gmail.com" | |
Allow "commiter2@gmail.com" | |
ReadCommiters | |
Verify | |
echo "Всем авторам присланных коммитов разрешено пушить." | |
echo "${Authors[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ' | |
} | |
Commiters=() | |
AllowedCommiters=() | |
Allow () { | |
AllowedCommiters+=($1) | |
} | |
ReadCommiters () { | |
while read oldsha newsha refname; do | |
Commiters+=($(git log $newsha -1 --pretty=format:%ce)) | |
done | |
} | |
Verify () { | |
for commiter in "${Commiters[@]}"; do | |
CheckCommiter $commiter | |
done | |
} | |
CheckCommiter () { | |
if echo "${AllowedCommiters[@]}" | grep -v "$1" >/dev/null ; then | |
echo "Комитеру $1 запрещено пушить в этот репо" | |
echo | |
echo "Разрешено комитерам: ${AllowedCommiters[@]}" | |
exit 1 | |
fi | |
} | |
Main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment