From aa500f0243133f2e9e0c912eea3497e52ebc1903 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Sep 2021 08:33:19 +0000 Subject: lei q|lcat: support "-f reply" output format When composing replies in "git format-patch" cover letters, I'd been relying on "lei q -f text ...", but that still requires several steps to make it suitable for composing a reply: * s/^/> / to quote the body * drop existing In-Reply-To+References * s/^Message-ID:/In-Reply-To:/; * add an attribute line ... "lei q -f reply" takes care of most of that and users will only have to trim "From " lines, unnecessary results and over-quoted text (and trimming is likely less error-prone than doing all the steps above manually). This should also be a good replacement for "git format-patch --in-reply-to=...", since copying long Message-IDs can be error-prone (and this lets you include quoted text in replies). --- t/lei-lcat.t | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't') diff --git a/t/lei-lcat.t b/t/lei-lcat.t index e5f00706..31a84744 100644 --- a/t/lei-lcat.t +++ b/t/lei-lcat.t @@ -11,6 +11,20 @@ test_lei(sub { lei_ok('import', 't/plack-qp.eml'); lei_ok([qw(lcat --stdin)], undef, { 0 => \$in, %$lei_opt }); like($lei_out, qr/qp\@example\.com/, 'got a result'); + + # test Link:, -f reply, and implicit --stdin: + my $prev = $lei_out; + $in = "\nLink: https://example.com/foo/qp\@example.com/\n"; + lei_ok([qw(lcat -f reply)], undef, { 0 => \$in, %$lei_opt}); + my $exp = <<'EOM'; +To: qp@example.com +Subject: Re: QP +In-Reply-To: + +On some unknown date, qp wrote: +> hi = bye +EOM + like($lei_out, qr/\AFrom [^\n]+\n\Q$exp\E/sm, '-f reply works'); }); done_testing; -- cgit v1.2.3-24-ge0c7