Skip to content

Instantly share code, notes, and snippets.

@kuronekomichael
Last active May 5, 2018 11:36
Show Gist options
  • Save kuronekomichael/808d18c401056945b7a4 to your computer and use it in GitHub Desktop.
Save kuronekomichael/808d18c401056945b7a4 to your computer and use it in GitHub Desktop.
user.nameやuser.emailが設定されていない時は、git commitを失敗させるフック
#!/bin/sh
# 一時フォルダの場合は特に制限を入れない
if [[ $PWD =~ ^/private/var/folders/ ]] ; then
exit 0
fi
if [ -z "`git config --local user.name`" ]; then
echo "\033[31m ✗ FATAL: user.name is not set locally \033[0m"
echo "\033[35mgit config user.name {your-name}\033[0m"
echo "\033[35mgit config user.email {[email protected]}\033[0m"
exit 1
fi
if [ -z "`git config --local user.email`" ]; then
echo "\033[31m ✗ FATAL: user.email is not set locally \033[0m"
echo "\033[35mgit config user.name {your-name}\033[0m"
echo "\033[35mgit config user.email {[email protected]}\033[0m"
exit 1
fi
@kuronekomichael
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment