diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-04-25 23:56:20 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-04-25 23:56:20 +0300 |
commit | c4c9d5586fed1b994ef579a0862b86ff36afcbe8 (patch) | |
tree | f05dacd2410a8e49e85aa2c0ef0f11c2d7ab2461 /t | |
parent | 80d268f30957e99904ceb087dff0b7ed6a61155a (diff) | |
parent | 3c8d3adeae8326d3b73fee0b134abd68d55f7c67 (diff) |
Merge branch 'rj/send-email-validate-hook-count-messages'
The sendemail-validate validate hook learned to pass the total
number of input files and where in the sequence each invocation is
via environment variables.
* rj/send-email-validate-hook-count-messages:
send-email: export patch counters in validate environment
Diffstat (limited to 't')
-rwxr-xr-x | t/t9001-send-email.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 0de83b5d2b..6520346246 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -2326,6 +2326,37 @@ test_expect_success $PREREQ 'invoke hook' ' ) ' +expected_file_counter_output () { + total=$1 + count=0 + while test $count -ne $total + do + count=$((count + 1)) && + echo "$count/$total" || return + done +} + +test_expect_success $PREREQ '--validate hook allows counting of messages' ' + test_when_finished "rm -rf my-hooks.log" && + test_config core.hooksPath "my-hooks" && + mkdir -p my-hooks && + + write_script my-hooks/sendemail-validate <<-\EOF && + num=$GIT_SENDEMAIL_FILE_COUNTER && + tot=$GIT_SENDEMAIL_FILE_TOTAL && + echo "$num/$tot" >>my-hooks.log || exit 1 + EOF + + >my-hooks.log && + expected_file_counter_output 4 >expect && + git send-email \ + --from="Example <from@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + --validate -3 --cover-letter --force && + test_cmp expect my-hooks.log +' + test_expect_success $PREREQ 'test that send-email works outside a repo' ' nongit git send-email \ --from="Example <nobody@example.com>" \ |