GNU bug report logs -
#63802
[mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header
Previous Next
Reported by: Arun Isaac <arunisaac <at> systemreboot.net>
Date: Tue, 30 May 2023 12:13:01 UTC
Severity: normal
Tags: patch
Done: Arun Isaac <arunisaac <at> systemreboot.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
* mumi/client.scm (serialize-email-address): New procedure.
(reply-email-headers): Use serialize-email-address.
* tests/client.scm (serialize-email-address): New variable.
("serialize email address", "serialize email address with comma in
name"): New tests.
---
mumi/client.scm | 14 ++++++++++----
tests/client.scm | 11 +++++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/mumi/client.scm b/mumi/client.scm
index 64ccbeb..c30429d 100644
--- a/mumi/client.scm
+++ b/mumi/client.scm
@@ -221,6 +221,14 @@ arguments."
(unless (zero? (close-pipe port))
(error "Command invocation failed" command))))))))
+(define (serialize-email-address name address)
+ "Combine NAME and ADDRESS into a complete email address of the form
+\"NAME <ADDRESS>\". Double quote NAME if necessary."
+ (string-append (if (string-contains name ",")
+ (string-append "\"" name "\"")
+ name)
+ " <" address ">"))
+
(define* (git-send-email to patches #:optional (options '()))
"Send PATCHES using git send-email to the TO address with
@@ -269,10 +277,8 @@ ISSUE-NUMBER."
,@(match (delete-duplicates
(map (lambda (message)
(let ((from (assoc-ref message "from")))
- (string-append (if (string-contains (assoc-ref from "name") ",")
- (string-append "\"" (assoc-ref from "name") "\"")
- (assoc-ref from "name"))
- " <" (assoc-ref from "address") ">")))
+ (serialize-email-address (assoc-ref from "name")
+ (assoc-ref from "address"))))
(vector->list (assoc-ref issue "messages"))))
(() (list))
(cc (list (cons 'cc (string-join cc ", "))))))))
diff --git a/tests/client.scm b/tests/client.scm
index 5352b08..2b2c1be 100644
--- a/tests/client.scm
+++ b/tests/client.scm
@@ -65,8 +65,19 @@ called with."
(lambda _
(error "Do not poll server for issue number"))))
+(define serialize-email-address
+ (@@ (mumi client) serialize-email-address))
+
(test-begin "client")
+(test-equal "serialize email address"
+ "Foo <foo <at> example.com>"
+ (serialize-email-address "Foo" "foo <at> example.com"))
+
+(test-equal "serialize email address with comma in name"
+ "\"Bar, Foo\" <foobar <at> example.com>"
+ (serialize-email-address "Bar, Foo" "foobar <at> example.com"))
+
(test-equal "send patches to new issue"
'(("git" "send-email" "--to=foo <at> patches.com" "foo.patch")
("git" "send-email" "--to=12345 <at> example.com" "bar.patch" "foobar.patch"))
--
2.39.2
This bug report was last modified 1 year and 115 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.