Re: [PATCH v2] send-email: export patch counters in validate environment
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 12, 2023, 21:48 UTC
- Message-ID
- <xmqqsfd46aca.fsf@gitster.g>
- In-Reply-To
- <xmqqfs957zs4.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Overall, a very well crafted patch, even though little details and > some design choices can be improved.
One thing I forgot to mention. We probably want some test, perhaps adding something like the following to t9001 after we already test for --validate.
Thanks.
----------- >8 ---------------------- >8 ---------------------- >8 -----------
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 my-hooks.log" && test_config core.hooksPath "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 1 >expect && git send-email \ --from="Example <from@example.com>" \ --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ --validate $patches && test_cmp expect my-hooks.log '