threads / patch / 30547

patchsend-email: support coloring dry-run output

Subject: [PATCH] send-email: support coloring dry-run output

## tl;dr

3 messages between May 17, 2012 and May 18, 2012. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Nguyễn Thái Ngọc Duy· May 17, 2012, 13:16 UTC · lore

It highlights sendmail command and subject lines. The most important lines to me.

I'm no Perl expert. This patch is by no means for submission. But maybe it'll motivate someone to do a proper patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git-send-email.perl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Show changes to git-send-email.perl +5 −1
diff --git a/git-send-email.perl b/git-send-email.perl
index ef30c55..033ca5e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1157,9 +1157,13 @@ X-Mailer: git-send-email $gitversion
 			    print "RCPT TO:<$entry>\n";
 			}
 		} else {
+			print color 'yellow';
 			print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
+			print color 'reset';
 		}
-		print $header, "\n";
+		my $colored_header = $header;
+		$colored_header =~ s/^(Subject: .*)/color("bold").$1.color("reset")/em;
+		print $colored_header, "\n";
 		if ($smtp) {
 			print "Result: ", $smtp->code, ' ',
 				($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
-- 
1.7.8.36.g69ee2
Angus Hammond· May 17, 2012, 14:27 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH] send-email: support coloring dry-run output

This seems like it would be a useful patch for those of us using sendmail. I'll admit I don't know any perl at all, but one bit seems a little odd to me. Is there a reason you use 3 separate print statements to deal with the colours on the Sendmail line, but a regex substitution the second time? I have no idea which would be considered the better practice but surely we should pick one and be consistent? Unless there's some difference between the two that I'm missing. Thanks Angus

Nguyen Thai Ngoc Duy· May 18, 2012, 04:26 UTC · re: Angus Hammond · lore

Re: [PATCH] send-email: support coloring dry-run output

On Thu, May 17, 2012 at 9:27 PM, Angus Hammond <angusgh@gmail.com> wrote:
Show 7 quoted lines
> This seems like it would be a useful patch for those of us using sendmail.
> I'll admit I don't know any perl at all, but one bit seems a little
> odd to me. Is there a reason you use 3 separate print statements to
> deal with the colours on the Sendmail line, but a regex substitution
> the second time? I have no idea which would be considered the better
> practice but surely we should pick one and be consistent? Unless
> there's some difference between the two that I'm missing.

No reasons. It was what I had in mind at that time and it worked, so I did not bother cleaning up or anything.

-- 
Duy

← back to recent threads