Commit Author Hook

Last modified by Craig Northway on 2018/02/16 18:07

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
Tags:
Created by Craig Northway on 2018/01/22 23:04
   
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 7.4.3 - Documentation