summaryrefslogtreecommitdiff
path: root/commit.d/50vcs-commit
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-07-22 11:24:10 -0400
committerJoey Hess <joey@kitenet.net>2013-07-22 11:24:10 -0400
commita890ac4a2ca4c9580b4a2e3a0c84f0ba249867dc (patch)
tree85a40a15402d5d54113aff8f9051728c72849385 /commit.d/50vcs-commit
parent45decda8bb533589bac429a66029598986a71b75 (diff)
Use user.name and user.email from the .gitconfig file belonging to the user who sued or sudoed to root, in preference to making up values for that user.
Diffstat (limited to 'commit.d/50vcs-commit')
-rwxr-xr-xcommit.d/50vcs-commit15
1 files changed, 15 insertions, 0 deletions
diff --git a/commit.d/50vcs-commit b/commit.d/50vcs-commit
index d484626..a700589 100755
--- a/commit.d/50vcs-commit
+++ b/commit.d/50vcs-commit
@@ -41,6 +41,21 @@ fi
if [ "$VCS" = git ] && [ -d .git ]; then
if [ -n "$USER" ]; then
+ # Use user.name and user.email from the gitconfig belonging
+ # to the user who became root.
+ USER_HOME="$(perl -e 'print ((getpwnam("joey"))[7])')"
+ if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.gitconfig" ]; then
+ if [ -z "$GIT_AUTHOR_NAME" ]; then
+ GIT_AUTHOR_NAME=$(git config -f "$USER_HOME/.gitconfig" user.name)
+ fi
+ if [ -z "$GIT_AUTHOR_EMAIL" ]; then
+ GIT_AUTHOR_EMAIL=$(git config -f "$USER_HOME/.gitconfig" user.email)
+ fi
+ fi
+ if [ -z "$GIT_COMMITTER_EMAIL" ]; then
+ GIT_COMMITER_EMAIL="$(git config --global user.email)"
+ fi
+
if [ -z "$GIT_AUTHOR_NAME" ]; then
export GIT_AUTHOR_NAME="$USER"
fi