From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 4Gb0N66+tWQL+QAASxT56A (envelope-from ) for ; Tue, 18 Jul 2023 00:20:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id iL7MN66+tWTqbQEA9RJhRA (envelope-from ) for ; Tue, 18 Jul 2023 00:20:30 +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 8D0234B9C8 for ; Tue, 18 Jul 2023 00:20:30 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=ERp4qYc2; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689632430; 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=Y4F8IAtxdSvYstMc95O1MVzT+4J3DPVl3euRSElbZyA=; b=bFMaVV8LX94YIe57P1VSFTQ61TEF0dC16O0Ht7qDGPpN2PsMXh51c4cQD4ILUjwbOY6Nuf uYYFR/FUByS2wjSHYouYGDyHr18UosuE7wdzZHalmKizUnjzZ/EoDDQ9zCePeGXSbNpk3K BOPyz3Dn8dGAlV1y3PGrxO0nAp1sSMcbQfbBMGAYRH5kl+sFcvAjesgqSAOw/Qp9GGseef 845E6f+qZlQzoj4NEgQgCXuMU9guc9YKXiHIFJMpB3jqTfjnHyEbq7j6bpT8xdho9IOXsa jyxOST7x/ZbRzPifpQNXEmiVMrPa6CqpwRcUYZvqBQYnX/MLu7is3+GrxEnNBg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689632430; a=rsa-sha256; cv=none; b=I3ek4qT75C/nsKTX0/9LYElIKUnrgYZhJ46gPaGFDOkg+9Uagh77GLFFJICZx38gjXOBi8 /tLvlaRrgBe6n6sY6mRLLUBck226Rh0MFUo1sOwcnwZvT8abU25POTWQ+LAfFysalIchfd ueH7PBKQvXv8AlhUHT8zndNeEFfRqyJhB4+kiAHofGje0DjsirVC3c04cZAESF3OCdnqcI Q47B/SOvmIcxXOyk4XOKOKwEJwMoXIaJU6iXjd/TrDnNAsNRL9LT06jZzTZNTmWBegcMVg PKYnImV99gQbkYB3Gvh509u7VjsB+JxEcEhAkf7MB3ImJYCx+MUYlJ750/SJDw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=ERp4qYc2; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLWZa-000254-Tg; Mon, 17 Jul 2023 18:20:07 -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 1qLWZX-00023x-Ke for guix-patches@gnu.org; Mon, 17 Jul 2023 18:20:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qLWZX-0004xh-Cd for guix-patches@gnu.org; Mon, 17 Jul 2023 18:20:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qLWZX-0002Q5-19; Mon, 17 Jul 2023 18:20:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63802] [PATCH 2/3] client: Add git-send-email-headers subcommand. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: arunisaac@systemreboot.net, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Mon, 17 Jul 2023 22:20: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.16896323779239 (code B ref 63802); Mon, 17 Jul 2023 22:20:02 +0000 Received: (at 63802) by debbugs.gnu.org; 17 Jul 2023 22:19:37 +0000 Received: from localhost ([127.0.0.1]:51085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLWZ6-0002Or-QM for submit@debbugs.gnu.org; Mon, 17 Jul 2023 18:19:37 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:51466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qLWZ4-0002OZ-1y for 63802@debbugs.gnu.org; Mon, 17 Jul 2023 18:19:35 -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: References:In-Reply-To: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:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Y4F8IAtxdSvYstMc95O1MVzT+4J3DPVl3euRSElbZyA=; b=ERp4qYc2yMCwXuVwiYkpW97JNZ HcJOCs+JkxxZYwmzxj2/3y1w3z56koIYk/xbB+5iaCivZmpVWfKu0UxOj4H/6rGYgWMtEW3IU75uJ W4lTNjVvdxToobcpvAHhhhnEZILICkU1wvvFlquCIWmKw4uHHfcs/d9+Hd5geDvVjEprEFbswqYjF olfID35IfT1douIX/sSwqzk32q7IPNayVv4X2iFC7yY6XNRzrMqzW0uqfsfCIv0micy4hjvTWKaXm Zu72EbDgort4/2wnoDsHPav1EaQwQ7x0a69x9pTBNQOn1oQIk64lDQvEB3BkEXxJMSuMn3k+8TG6b 80B/U3QA==; Received: from [192.168.2.1] (port=50314 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 1qLWZ1-001Gpv-0U; Mon, 17 Jul 2023 23:19:31 +0100 From: Arun Isaac Date: Mon, 17 Jul 2023 23:19:20 +0100 Message-Id: <20230717221921.28889-2-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230717221921.28889-1-arunisaac@systemreboot.net> References: <20230717221921.28889-1-arunisaac@systemreboot.net> 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: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.06 X-Spam-Score: -2.06 X-Migadu-Queue-Id: 8D0234B9C8 X-Migadu-Scanner: mx1.migadu.com X-TUID: PH3NrjYZzx0h * mumi/client.scm: Import (rnrs exceptions). (git-send-email-headers): New public procedure. (split-cc): New procedure. * scripts/mumi.in: Add git-send-email-headers subcommand. * tests/client.scm (split-cc): New variable. ("split Cc field"): New test. --- mumi/client.scm | 51 +++++++++++++++++++++++++++++++++++++++++++++++- scripts/mumi.in | 2 ++ tests/client.scm | 8 ++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/mumi/client.scm b/mumi/client.scm index c30429d..797ec91 100644 --- a/mumi/client.scm +++ b/mumi/client.scm @@ -17,6 +17,7 @@ ;;; along with mumi. If not, see . (define-module (mumi client) + #:use-module (rnrs exceptions) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) @@ -38,7 +39,8 @@ print-current-issue set-current-issue! clear-current-issue! - send-email)) + send-email + git-send-email-headers)) (define (git-top-level) "Return the top-level directory of the current git repository." @@ -229,6 +231,13 @@ arguments." name) " <" address ">")) +(define (split-cc cc) + "Split CC into a list of email addresses." + (map (lambda (address) + (serialize-email-address (assq-ref address 'name) + (assq-ref address 'address))) + (assq-ref (parse-email-headers (string-append "Cc: " cc "\n")) + 'cc))) (define* (git-send-email to patches #:optional (options '())) "Send PATCHES using git send-email to the TO address with @@ -311,3 +320,43 @@ ISSUE-NUMBER." "@" (client-config 'debbugs-host)) other-patches))))) + +(define (git-send-email-headers patch) + "Print send-email headers for PATCH." + (let* (;; Compute headers if configured in git config. + (header-command + (false-if-exception + (call-with-input-pipe* (list "git" "config" "sendemail.headerCmd") + get-line))) + (headers + (if header-command + (call-with-input-pipe (string-append header-command " " patch) + get-string-all) + "")) + (external-x-debbugs-cc + (cond + ((assq-ref (parse-email-headers (string-append headers "\n")) + 'x-debbugs-cc) + => split-cc) + (else '()))) + ;; Fetch Cc addresses for current issue. + (x-debbugs-cc + (cond + ((assq-ref (reply-email-headers (current-issue-number)) + 'cc) + => split-cc) + (else '())))) + ;; Print X-Debbugs-Cc header. + (display "X-Debbugs-Cc: ") + (display (string-join (delete-duplicates + (append x-debbugs-cc external-x-debbugs-cc)) + ", ")) + (newline) + ;; Print headers other than X-Debbugs-Cc. + ;; TODO: RFC5322 headers are not restricted to a single + ;; line. "Folded" multi-line headers are allowed. Support them. + (for-each (lambda (line) + (unless (string-prefix-ci? "X-Debbugs-Cc:" line) + (display line) + (newline))) + (string-split headers #\newline)))) diff --git a/scripts/mumi.in b/scripts/mumi.in index 2295328..8fb7cd4 100644 --- a/scripts/mumi.in +++ b/scripts/mumi.in @@ -163,6 +163,8 @@ (client:clear-current-issue!)) (("send-email" . patches) (client:send-email patches)) + (("git-send-email-headers" patch) + (client:git-send-email-headers patch)) (("mailer" . rest) (let* ((opts (parse-options rest)) (sender (assoc-ref opts 'sender)) diff --git a/tests/client.scm b/tests/client.scm index 2b2c1be..ced573b 100644 --- a/tests/client.scm +++ b/tests/client.scm @@ -68,6 +68,9 @@ called with." (define serialize-email-address (@@ (mumi client) serialize-email-address)) +(define split-cc + (@@ (mumi client) split-cc)) + (test-begin "client") (test-equal "serialize email address" @@ -78,6 +81,11 @@ called with." "\"Bar, Foo\" " (serialize-email-address "Bar, Foo" "foobar@example.com")) +(test-equal "split Cc field" + (list "Foo " + "\"Bar, Foo\" ") + (split-cc "Foo , \"Bar, Foo\" ")) + (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