mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
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 <gitster@pobox.com>
This commit is contained in:
parent
4b340cfab9
commit
04861982e5
1 changed files with 18 additions and 0 deletions
|
@ -118,4 +118,22 @@ test_expect_success 'with failing hook requiring GIT_PREFIX' '
|
|||
git checkout -- file
|
||||
'
|
||||
|
||||
test_expect_failure 'check the author in hook' '
|
||||
write_script "$HOOK" <<-\EOF &&
|
||||
test "$GIT_AUTHOR_NAME" = "New Author" &&
|
||||
test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com"
|
||||
EOF
|
||||
test_must_fail git commit --allow-empty -m "by a.u.thor" &&
|
||||
(
|
||||
GIT_AUTHOR_NAME="New Author" &&
|
||||
GIT_AUTHOR_EMAIL="newauthor@example.com" &&
|
||||
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
|
||||
git commit --allow-empty -m "by new.author via env" &&
|
||||
git show -s
|
||||
) &&
|
||||
git commit --author="New Author <newauthor@example.com>" \
|
||||
--allow-empty -m "by new.author via command line" &&
|
||||
git show -s
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue