diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-05-30 11:16:43 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-30 11:16:43 +0900 |
commit | 07d4c760056b930246d5db1545c32d3cecd9d257 (patch) | |
tree | 115195d11469f1e20f8be19643fd6b7e748e392b /t | |
parent | Merge branch 'jh/memihash-opt' (diff) | |
parent | send-email: support validate hook (diff) | |
download | tgif-07d4c760056b930246d5db1545c32d3cecd9d257.tar.xz |
Merge branch 'jt/send-email-validate-hook'
"git send-email" learned to run sendemail-validate hook to inspect
and reject a message before sending it out.
* jt/send-email-validate-hook:
send-email: support validate hook
Diffstat (limited to 't')
-rwxr-xr-x | t/t9001-send-email.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 60a80f60b2..15128c755a 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1913,4 +1913,44 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' ' test_cmp expected-list actual-list ' +test_expect_success $PREREQ 'invoke hook' ' + mkdir -p .git/hooks && + + write_script .git/hooks/sendemail-validate <<-\EOF && + # test that we have the correct environment variable, pwd, and + # argument + case "$GIT_DIR" in + *.git) + true + ;; + *) + false + ;; + esac && + test -f 0001-add-master.patch && + grep "add master" "$1" + EOF + + mkdir subdir && + ( + # Test that it works even if we are not at the root of the + # working tree + cd subdir && + git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/../fake.sendmail" \ + ../0001-add-master.patch && + + # Verify error message when a patch is rejected by the hook + sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch && + git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/../fake.sendmail" \ + ../another.patch 2>err + test_i18ngrep "rejected by sendemail-validate hook" err + ) +' + test_done |