Created
September 5, 2012 13:45
-
-
Save ngyuki/3636779 to your computer and use it in GitHub Desktop.
[hatena 20120905] Git でサーバに認証したユーザと Author が同じであることを強制するフックスクリプト
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 | |
RETVAL=0 | |
while read HASH_OLD HASH_NEW REFNAME; do | |
( | |
git log --format=format:"%H%x09%an%x09%ae" ${HASH_OLD}..${HASH_NEW} | |
echo | |
) | | |
( | |
IFS=$'\t' | |
while read HASH_CUR AUTHOR_NAME AUTHOR_MAIL; do | |
if [ "${SSH_GIT_USER}" != "${AUTHOR_NAME}" -o "${SSH_GIT_MAIL}" != "${AUTHOR_MAIL}" ]; then | |
echo "Author NG ... ${HASH_CUR} ${AUTHOR_NAME} <${AUTHOR_MAIL}> != ${SSH_GIT_USER} <${SSH_GIT_MAIL}>" 1>&2 | |
RETVAL=1 | |
else | |
echo "Author OK ... ${HASH_CUR} ${AUTHOR_NAME} <${AUTHOR_MAIL}>" 1>&2 | |
fi | |
done | |
exit $RETVAL | |
) | |
if [ "$?" -ne 0 ]; then | |
RETVAL=1 | |
fi | |
done | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment