Commit Author Hook
Last modified by superadmin on 2020/04/18 20:53
Commit Author Hook
The following pre-commit hook will enable confirmation that a specific e-mail address was used in the author information in the commit message. To enable this you will need to copy this content into the .git/hooks/pre-commit file, remove the .git/hooks/pre-commit.sample file and set the hook to executable chmod +x .git/hooks/pre-commit.
#!/bin/sh
AUTHORINFO=$(git var GIT_AUTHOR_IDENT) || exit 1
echo "$AUTHORINFO"
#(?<=@)([^.]+)(?=\.)
EMAIL_DOMAIN=$(printf '%s\n' "$AUTHORINFO" | grep -o '@codeaurora.org')
echo "$EMAIL_DOMAIN"
if [ "$EMAIL_DOMAIN" != "@codeaurora.org" ];
then
cat <<EOF >&2
Please commit with the correct codeaurora.org domain name.
Your author information was $AUTHORINFO
EOF
exit 1
fi
exit 0
AUTHORINFO=$(git var GIT_AUTHOR_IDENT) || exit 1
echo "$AUTHORINFO"
#(?<=@)([^.]+)(?=\.)
EMAIL_DOMAIN=$(printf '%s\n' "$AUTHORINFO" | grep -o '@codeaurora.org')
echo "$EMAIL_DOMAIN"
if [ "$EMAIL_DOMAIN" != "@codeaurora.org" ];
then
cat <<EOF >&2
Please commit with the correct codeaurora.org domain name.
Your author information was $AUTHORINFO
EOF
exit 1
fi
exit 0