From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ECAyJQQNgmSibwEASxT56A (envelope-from ) for ; Thu, 08 Jun 2023 19:16:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id +HTsIwQNgmSIkAAAG6o9tA (envelope-from ) for ; Thu, 08 Jun 2023 19:16:52 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6465828EEF for ; Thu, 8 Jun 2023 19:16:47 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=dIC672Lx; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1686244608; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=VLicOmtPWuLioUpjienGnh8ece+vix/OAeeBScqY8zU=; b=qWJQbjWxi3O36wlLdl0X3pvI3rgnOds3nvg7Q+NqiLE8Uow+yemgkSYpPpB8wYdGww+gpZ elBzKbWlR3o2105QNBjGpRD2hS8fE9Uexa6F6FxxsbmMCDEi4hoFBrPtHfAKIBUondWJ9a qj8xT6RIsBtSWO94Vdyt6Cvikx6nHA7SKPEONEMkzvJdmZcpdP/w+x0JyIIZxV36zDcggf Jj2FG7osZqY1uhAyJZgjNmF4big7kdc9dKJY8LvE3qydvAhZcT8bhsTGYbc5hFkWl4UVUM QDfFaNWkhr3AV/pWyCwdclWgwR8SXYDW9TxLhrwyqZyJimxYHa7C5gp/PCVIuQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=dIC672Lx; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1686244608; a=rsa-sha256; cv=none; b=X5ihCxjyNeOngBE1hxlxQON+cxhsD7695rz+El1e8haarkkO48KxTDNZnu5LZxsF858ffN Z2rucjSESuEPV8J3L58ukWdkqH+k6wYXQKjjkNX34knTYqRjFcRAtb4Y/dlYaRcEnvmMWe erIftX9W3I+X4gpnrtc4Fsv4Ujz8YM7Avnt514Dr748i9ygaglbVqVl/qwOscNsr5lVvxT Tpp/Y7Ekd12rais0e3U9COADxO8B8wnXdsEyowSK/LDSMoGHT7NfgPTK3a6Edu+Rygw4Uq s8JHQfNA4BFWWs36EptenXWRHMx5LYfRB5XDQeHGZUC8RPZkpHpnVJrXOdcUGg== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7JEz-0003T5-Oj; Thu, 08 Jun 2023 13:16:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7JEy-0003Rn-3G for guix-patches@gnu.org; Thu, 08 Jun 2023 13:16:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7JEx-0007jH-Qu for guix-patches@gnu.org; Thu, 08 Jun 2023 13:16:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q7JEw-0008P4-EF; Thu, 08 Jun 2023 13:16:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63802] [PATCH 1/3] client: Separate serialize-email-address into a function. References: <20230530121132.26057-1-arunisaac@systemreboot.net> In-Reply-To: <20230530121132.26057-1-arunisaac@systemreboot.net> Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: arunisaac@systemreboot.net, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 08 Jun 2023 17:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63802 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63802@debbugs.gnu.org Cc: Arun Isaac , Arun Isaac , Maxim Cournoyer X-Debbugs-Original-Xcc: Arun Isaac , Maxim Cournoyer Received: via spool by 63802-submit@debbugs.gnu.org id=B63802.168624452832244 (code B ref 63802); Thu, 08 Jun 2023 17:16:02 +0000 Received: (at 63802) by debbugs.gnu.org; 8 Jun 2023 17:15:28 +0000 Received: from localhost ([127.0.0.1]:57432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7JEO-0008Nv-CC for submit@debbugs.gnu.org; Thu, 08 Jun 2023 13:15:28 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:53218) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7JEI-0008NM-KY for 63802@debbugs.gnu.org; Thu, 08 Jun 2023 13:15:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VLicOmtPWuLioUpjienGnh8ece+vix/OAeeBScqY8zU=; b=dIC672Lxoj07WIf1SZT8PEYGgQ WAuclSB1MhnjLzGp/4wYHZSizFxjNGcgVvoy8/VECue/fKPoeMK5dpSd5MRBeXr1L4NrYfJeVC2GY dV7BXQnwW+PlSgXzkF7p8tisMrG7nEPzJs9rCoVCdwAc5USu1JC3EcN7zNe2O10Th5LPLtRBHdSNV WmMZ5UOysyHtK5AAoG8mBxcVrLlo/+ztL2lJRKhYu6TBJLJ+UMWa/W37q9hn805rSa/TRLwJZuL4D O5YbBBSkoHNiVcefZlfCQsKsghrzF92/fQbbXJDCD6irsg9OKiBcppviNcVG8Qh0NZHAB4FSfStGE t23oCDzQ==; Received: from [192.168.2.1] (port=42546 helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1q7JED-000UaF-39; Thu, 08 Jun 2023 18:15:18 +0100 From: Arun Isaac Date: Thu, 8 Jun 2023 18:14:50 +0100 Message-Id: <20230608171453.14788-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: UNKNOWN X-Migadu-Flow: FLOW_IN X-Spam-Score: 2.05 X-Migadu-Queue-Id: 6465828EEF X-Migadu-Scanner: in3.migadu.com X-Migadu-Spam-Score: 2.05 X-TUID: bGQJnzHFs/t5 * 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
\". 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 " + (serialize-email-address "Foo" "foo@example.com")) + +(test-equal "serialize email address with comma in name" + "\"Bar, Foo\" " + (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