user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
commit 90ca1ac28edb2e8a64c30bb4be723643c646df89
Author: Stavros Ntentos <stdedos@gmail.com>
Date:   Fri Mar 26 18:31:46 2021 +0200

    git-send-email-reply: Append subject
    
    I keep copy-pasting the addresses provided,
    I keep writing my plaintext reply in a file,
    and I keep forgetting to add a subject
    (because I am "just" writing a plaintext file)
    
    Teach `git-send-email-reply` to append a `--subject` line.
    
    [ew: avoid URI-encoded subject on command-line, adjust t/reply.t]
    
    Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>

diff --git a/lib/PublicInbox/Reply.pm b/lib/PublicInbox/Reply.pm
index 8226fdc3..2a1066d2 100644
--- a/lib/PublicInbox/Reply.pm
+++ b/lib/PublicInbox/Reply.pm
@@ -74,6 +74,7 @@ sub mailto_arg_link {
 	my $obfs = $ibx->{obfuscate};
 	my $subj = $hdr->header('Subject') || '';
 	$subj = "Re: $subj" unless $subj =~ /\bRe:/i;
+	my $subj_raw = $subj;
 	my $mid = $hdr->header_raw('Message-ID');
 	push @arg, '--in-reply-to='.squote_maybe(mid_clean($mid));
 	my $irt = mid_href($mid);
@@ -103,6 +104,8 @@ sub mailto_arg_link {
 		}
 	}
 
+	push @arg, "--subject=".squote_maybe($subj_raw);
+
 	# I'm not sure if address obfuscation and mailto: links can
 	# be made compatible; and address obfuscation is misguided,
 	# anyways.
diff --git a/t/reply.t b/t/reply.t
index 0b8e1f38..1e89973e 100644
--- a/t/reply.t
+++ b/t/reply.t
@@ -36,7 +36,8 @@ my $exp = [
     '--in-reply-to=blah@example.com',
     '--to=from@example.com',
     '--cc=cc@example.com',
-    '--cc=to@example.com'
+    '--cc=to@example.com',
+    "--subject='Re: hihi'"
 ];
 
 is_deeply($arg, $exp, 'default reply is to :all');
@@ -44,7 +45,8 @@ $ibx->{replyto} = ':all';
 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
 is_deeply($arg, $exp, '":all" also works');
 
-$exp = [ '--in-reply-to=blah@example.com', '--to=primary@example.com' ];
+$exp = [ '--in-reply-to=blah@example.com', '--to=primary@example.com',
+	"--subject='Re: hihi'" ];
 $ibx->{replyto} = ':list';
 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
 is_deeply($arg, $exp, '":list" works for centralized lists');
@@ -53,7 +55,8 @@ $exp = [
 	 '--in-reply-to=blah@example.com',
 	 '--to=primary@example.com',
 	 '--cc=cc@example.com',
-	 '--cc=to@example.com'
+	 '--cc=to@example.com',
+	"--subject='Re: hihi'"
 ];
 $ibx->{replyto} = ':list,Cc,To';
 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
@@ -61,7 +64,9 @@ is_deeply($arg, $exp, '":list,Cc,To" works for kinda centralized lists');
 
 $ibx->{replyto} = 'new@example.com';
 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
-$exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com' ];
+$exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com',
+	"--subject='Re: hihi'"
+];
 is_deeply($arg, $exp, 'explicit address works, too');
 
 $ibx->{replyto} = ':all';
@@ -71,7 +76,8 @@ $exp = [
     '--in-reply-to=blah@example.com',
     '--to=from@example$(echo .)com',
     '--cc=cc@example$(echo .)com',
-    '--cc=to@example$(echo .)com'
+    '--cc=to@example$(echo .)com',
+    "--subject='Re: hihi'"
 ];
 is_deeply($arg, $exp, 'address obfuscation works');
 is($link, '', 'no mailto: link given');

debug log:

solving 90ca1ac28edb2e8a64c30bb4be723643c646df89 ...
found 90ca1ac28edb2e8a64c30bb4be723643c646df89 in https://80x24.org/public-inbox.git

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).