зеркало из https://github.com/microsoft/git.git
Merge branch 'tr/send-email-refuse-sending-unedited-cover-letter' into maint
* tr/send-email-refuse-sending-unedited-cover-letter: send-email: Refuse to send cover-letter template subject
This commit is contained in:
Коммит
71d35bdb36
|
@ -85,6 +85,7 @@ git send-email [options] <file | directory | rev-list options >
|
||||||
--[no-]validate * Perform patch sanity checks. Default on.
|
--[no-]validate * Perform patch sanity checks. Default on.
|
||||||
--[no-]format-patch * understand any non optional arguments as
|
--[no-]format-patch * understand any non optional arguments as
|
||||||
`git format-patch` ones.
|
`git format-patch` ones.
|
||||||
|
--force * Send even if safety checks would prevent it.
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -162,6 +163,7 @@ if ($@) {
|
||||||
my ($quiet, $dry_run) = (0, 0);
|
my ($quiet, $dry_run) = (0, 0);
|
||||||
my $format_patch;
|
my $format_patch;
|
||||||
my $compose_filename;
|
my $compose_filename;
|
||||||
|
my $force = 0;
|
||||||
|
|
||||||
# Handle interactive edition of files.
|
# Handle interactive edition of files.
|
||||||
my $multiedit;
|
my $multiedit;
|
||||||
|
@ -301,6 +303,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
|
||||||
"validate!" => \$validate,
|
"validate!" => \$validate,
|
||||||
"format-patch!" => \$format_patch,
|
"format-patch!" => \$format_patch,
|
||||||
"8bit-encoding=s" => \$auto_8bit_encoding,
|
"8bit-encoding=s" => \$auto_8bit_encoding,
|
||||||
|
"force" => \$force,
|
||||||
);
|
);
|
||||||
|
|
||||||
unless ($rc) {
|
unless ($rc) {
|
||||||
|
@ -702,6 +705,16 @@ if (!defined $auto_8bit_encoding && scalar %broken_encoding) {
|
||||||
default => "UTF-8");
|
default => "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$force) {
|
||||||
|
for my $f (@files) {
|
||||||
|
if (get_patch_subject($f) =~ /\*\*\* SUBJECT HERE \*\*\*/) {
|
||||||
|
die "Refusing to send because the patch\n\t$f\n"
|
||||||
|
. "has the template subject '*** SUBJECT HERE ***'. "
|
||||||
|
. "Pass --force if you really want to send.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $prompting = 0;
|
my $prompting = 0;
|
||||||
if (!defined $sender) {
|
if (!defined $sender) {
|
||||||
$sender = $repoauthor || $repocommitter || '';
|
$sender = $repoauthor || $repocommitter || '';
|
||||||
|
|
|
@ -1032,4 +1032,40 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
# Note that the patches in this test are deliberately out of order; we
|
||||||
|
# want to make sure it works even if the cover-letter is not in the
|
||||||
|
# first mail.
|
||||||
|
test_expect_success 'refusing to send cover letter template' '
|
||||||
|
clean_fake_sendmail &&
|
||||||
|
rm -fr outdir &&
|
||||||
|
git format-patch --cover-letter -2 -o outdir &&
|
||||||
|
test_must_fail git send-email \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
outdir/0002-*.patch \
|
||||||
|
outdir/0000-*.patch \
|
||||||
|
outdir/0001-*.patch \
|
||||||
|
2>errors >out &&
|
||||||
|
grep "SUBJECT HERE" errors &&
|
||||||
|
test -z "$(ls msgtxt*)"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--force sends cover letter template anyway' '
|
||||||
|
clean_fake_sendmail &&
|
||||||
|
rm -fr outdir &&
|
||||||
|
git format-patch --cover-letter -2 -o outdir &&
|
||||||
|
git send-email \
|
||||||
|
--force \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
outdir/0002-*.patch \
|
||||||
|
outdir/0000-*.patch \
|
||||||
|
outdir/0001-*.patch \
|
||||||
|
2>errors >out &&
|
||||||
|
! grep "SUBJECT HERE" errors &&
|
||||||
|
test -n "$(ls msgtxt*)"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче