Skip to content

Instantly share code, notes, and snippets.

@ShaneQi
Last active February 5, 2020 23:35
Show Gist options
  • Save ShaneQi/12cdd0ac8fee1782e156384884497fe1 to your computer and use it in GitHub Desktop.
Save ShaneQi/12cdd0ac8fee1782e156384884497fe1 to your computer and use it in GitHub Desktop.
git pre-commit hook for checking author name & email
// The tutorial of setting this up:
// https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook
if [[ $(git remote) =~ "origin" ]]
then
if [[ $(git config user.name) != "Shane Qi" ]]
then
echo "Incorrect author name."
exit 1
fi
if [[ $(git remote get-url origin) =~ "github.com" ]]
then
if [[ $(git config user.email) != "qizengtai@gmail.com" ]]
then
echo "Incorrect author email."
exit 1
fi
fi
if [[ $(git remote get-url origin) =~ "axxess.net" ]]
then
if [[ $(git config user.email) != "zqi@axxess.com" ]]
then
echo "Incorrect author email."
exit 1
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment