Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -41,14 +41,13 @@ Use the commands
to introduce yourself to Git before committing.'
# Ensure name and email are available.
git config --get user.name > /dev/null &&
git config --get user.email > /dev/null ||
git var GIT_AUTHOR_IDENT > /dev/null ||
die 'Identity not configured!' "$advice"
# Validate the name and email.
git config --get user.name | grep ' ' > /dev/null ||
git var GIT_AUTHOR_IDENT | cut -d "<" -f1 | sed 's,\s$,,' | grep ' ' > /dev/null ||
die 'Set user.name to your Real Name (with a space), not a userid.' "$advice"
git config --get user.email | grep '^[^@]*@[^@]*$' > /dev/null ||
git var GIT_AUTHOR_IDENT | cut -d ">" -f1 | cut -d "<" -f2 | grep '^[^@]*@[^@]*$' > /dev/null ||
die 'Set user.email to an email address (userid@validdomain.com).' "$advice"
#-----------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment