Skip to content

Commit 0486198

Browse files
committed
t7503: does pre-commit-hook learn authorship?
When "--author" option is used to lie the authorship to "git commit" command, hooks should learn the author name and email just like when GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables are used to lie the authorship. Test this. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4b340cf commit 0486198

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

t/t7503-pre-commit-hook.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,22 @@ test_expect_success 'with failing hook requiring GIT_PREFIX' '
118118
git checkout -- file
119119
'
120120

121+
test_expect_failure 'check the author in hook' '
122+
write_script "$HOOK" <<-\EOF &&
123+
test "$GIT_AUTHOR_NAME" = "New Author" &&
124+
test "$GIT_AUTHOR_EMAIL" = "[email protected]"
125+
EOF
126+
test_must_fail git commit --allow-empty -m "by a.u.thor" &&
127+
(
128+
GIT_AUTHOR_NAME="New Author" &&
129+
GIT_AUTHOR_EMAIL="[email protected]" &&
130+
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
131+
git commit --allow-empty -m "by new.author via env" &&
132+
git show -s
133+
) &&
134+
git commit --author="New Author <[email protected]>" \
135+
--allow-empty -m "by new.author via command line" &&
136+
git show -s
137+
'
138+
121139
test_done

0 commit comments

Comments
 (0)