Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-30 05:16:43 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-30 05:16:43 +0300
commit07d4c760056b930246d5db1545c32d3cecd9d257 (patch)
tree115195d11469f1e20f8be19643fd6b7e748e392b /t
parentc05e1231dac6d7582c370a57464c46950ef70a99 (diff)
parent6489660b4bba7456fac0d0a41f5d6295c5900c5f (diff)
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-xt/t9001-send-email.sh40
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