Created
January 25, 2021 21:31
-
-
Save particleflux/27759f807fad6b7e1e7af28dfb695b1e to your computer and use it in GitHub Desktop.
Check git user config on first local commit
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
#!/usr/bin/env bash | |
verified=$(git config --type=bool hooks.userverified) | |
# grab input | |
exec < /dev/tty | |
exec 1>&2 | |
if [[ "$verified" != "true" ]]; then | |
echo "Checking committer info..." | |
echo "Current author information:" | |
echo "$(git config user.name) <$(git config user.email)>" | |
while read -p "Is the author set correct? (y/n) " yn; do | |
case $yn in | |
[Yy] ) | |
echo "First local commit correct, disabled check" | |
git config hooks.userverified true | |
break | |
;; | |
[Nn] ) | |
echo "Please update author info!"; | |
exit 1 | |
;; | |
* ) | |
echo "Please answer y (yes) or n (no):" && continue; | |
esac | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Small note: You should probably run
git config --global init.templatedir ~/.git-templates
to configure the template dir globally.