Commit d033ed35 authored by Arkadiusz Drabczyk's avatar Arkadiusz Drabczyk
Browse files

pre-commit: switch to git-var to check if username and e-mail are set

In git, apart from setting username and e-mail in .gitconfig it's also
possible to set username in /etc/passwd and set e-mail using EMAIL
environment variable.  The advantage of this method is that other
programs such as mutt or doxygen will pick up these settings up so
there is no need to set them separately in each program.  Current way
of checking if username and e-mail are set using git config results in
failure if they are set using this method.
parent 5fd92817
......@@ -41,14 +41,13 @@ Use the commands
to introduce yourself to Git before committing.'
# Ensure name and email are available.
git config --get > /dev/null &&
git config --get > /dev/null ||
git var GIT_AUTHOR_IDENT > /dev/null ||
die 'Identity not configured!' "$advice"
# Validate the name and email.
git config --get | grep ' ' > /dev/null ||
git var GIT_AUTHOR_IDENT | cut -d "<" -f1 | sed 's,\s$,,' | grep ' ' > /dev/null ||
die 'Set to your Real Name (with a space), not a userid.' "$advice"
git config --get | grep '^[^@]*@[^@]*$' > /dev/null ||
git var GIT_AUTHOR_IDENT | cut -d ">" -f1 | cut -d "<" -f2 | grep '^[^@]*@[^@]*$' > /dev/null ||
die 'Set to an email address (' "$advice"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment