From: Arun Isaac <arunisaac@systemreboot.net>
To: 63802@debbugs.gnu.org
Cc: Arun Isaac <arunisaac@systemreboot.net>,
Arun Isaac <arunisaac@systemreboot.net>,
Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#63802] [PATCH 1/3] client: Separate serialize-email-address into a function.
Date: Thu, 8 Jun 2023 18:14:50 +0100 [thread overview]
Message-ID: <20230608171453.14788-1-arunisaac@systemreboot.net> (raw)
In-Reply-To: <20230530121132.26057-1-arunisaac@systemreboot.net>
* mumi/client.scm (serialize-email-address): New function.
(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@example.com>"
+ (serialize-email-address "Foo" "foo@example.com"))
+
+(test-equal "serialize email address with comma in name"
+ "\"Bar, Foo\" <foobar@example.com>"
+ (serialize-email-address "Bar, Foo" "foobar@example.com"))
+
(test-equal "send patches to new issue"
'(("git" "send-email" "--to=foo@patches.com" "foo.patch")
("git" "send-email" "--to=12345@example.com" "bar.patch" "foobar.patch"))
--
2.39.2
next prev parent reply other threads:[~2023-06-08 17:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 12:11 [bug#63802] [mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header Arun Isaac
2023-05-30 12:14 ` [bug#63802] [mumi PATCH 1/3] client: Do not pass --add-header to git send-email Arun Isaac
2023-05-30 12:14 ` [bug#63802] [mumi PATCH 2/3] client: Add git-send-email-headers subcommand Arun Isaac
2023-06-05 2:31 ` Maxim Cournoyer
2023-06-08 17:09 ` Arun Isaac
2023-06-08 17:29 ` Arun Isaac
2023-05-30 12:14 ` [bug#63802] [mumi PATCH 3/3] client: Use mumi " Arun Isaac
2023-06-05 2:36 ` Maxim Cournoyer
2023-06-05 2:21 ` [bug#63802] [mumi PATCH 1/3] client: Do not pass --add-header to git send-email Maxim Cournoyer
2023-06-08 17:14 ` Arun Isaac [this message]
2023-06-08 17:14 ` [bug#63802] [PATCH 2/3] client: Add git-send-email-headers subcommand Arun Isaac
2023-07-16 3:39 ` [bug#63802] [mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header Maxim Cournoyer
2023-07-17 22:14 ` Arun Isaac
2023-07-18 15:32 ` Maxim Cournoyer
2023-07-19 16:49 ` bug#63802: " Arun Isaac
2023-06-08 17:14 ` [bug#63802] [PATCH 3/3] client: Use mumi git-send-email-headers subcommand Arun Isaac
2023-07-16 4:01 ` [bug#63802] [mumi PATCH 0/3] Use consolidated X-Debbugs-Cc header Maxim Cournoyer
2023-07-17 22:14 ` Arun Isaac
2023-07-16 3:14 ` Maxim Cournoyer
2023-07-17 22:19 ` [bug#63802] [PATCH 1/3] client: Separate serialize-email-address into a procedure Arun Isaac
2023-07-17 22:19 ` [bug#63802] [PATCH 2/3] client: Add git-send-email-headers subcommand Arun Isaac
2023-07-17 22:19 ` [bug#63802] [PATCH 3/3] client: Use mumi " Arun Isaac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230608171453.14788-1-arunisaac@systemreboot.net \
--to=arunisaac@systemreboot.net \
--cc=63802@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.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).