Skip to content

Instantly share code, notes, and snippets.

@particleflux
Created January 25, 2021 21:31
Show Gist options
  • Save particleflux/27759f807fad6b7e1e7af28dfb695b1e to your computer and use it in GitHub Desktop.
Save particleflux/27759f807fad6b7e1e7af28dfb695b1e to your computer and use it in GitHub Desktop.
Check git user config on first local commit
#!/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
@DBX12
Copy link

DBX12 commented Jan 26, 2021

Small note: You should probably run git config --global init.templatedir ~/.git-templates to configure the template dir globally.

@particleflux
Copy link
Author

Indeed, fixed above, thx.

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