From patchwork Mon May 1 21:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Isaac X-Patchwork-Id: 49733 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 065EC27BBEA; Mon, 1 May 2023 22:03:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3983F27BBE2 for ; Mon, 1 May 2023 22:03:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptafo-0005iq-3m; Mon, 01 May 2023 17:03:04 -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 1ptafm-0005ia-JY for guix-patches@gnu.org; Mon, 01 May 2023 17:03:02 -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 1ptafm-000466-Ar for guix-patches@gnu.org; Mon, 01 May 2023 17:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ptafl-0006Zv-Vm for guix-patches@gnu.org; Mon, 01 May 2023 17:03:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63215] [PATCH mumi 1/2] client: Support passing options to git send-email. References: <20230501205639.16201-1-arunisaac@systemreboot.net> In-Reply-To: <20230501205639.16201-1-arunisaac@systemreboot.net> Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 01 May 2023 21:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63215 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63215@debbugs.gnu.org Cc: Arun Isaac Received: via spool by 63215-submit@debbugs.gnu.org id=B63215.168297493525224 (code B ref 63215); Mon, 01 May 2023 21:03:01 +0000 Received: (at 63215) by debbugs.gnu.org; 1 May 2023 21:02:15 +0000 Received: from localhost ([127.0.0.1]:41162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptaf0-0006Yl-NS for submit@debbugs.gnu.org; Mon, 01 May 2023 17:02:14 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:51314) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptaey-0006YV-Eh for 63215@debbugs.gnu.org; Mon, 01 May 2023 17:02:13 -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=GS5z0c4uMKIYg/s/5mo/B0Ggam8gi+s26/147IVrY6U=; b=JCM74dpjyap33AEIhFjiOHNmps tAF7xYCOq11Dw0Qeq+SXEA8peFImG3vRR5Yxgvi5NZoxkPd2ne7KewWf5QqBely5SuwOPaQC7E5/C PFtRPDiM4EQ2tj93iPzmAPe9v4X1X30t/j4nVcslkyDRrqT/hW6uBViIG9R6USkfkKOWO3pvlutKw JAdYZ+2K1j4ekzz6Qe9s5MXnK1Hv9tOd5DrSqH1sG5i9gZtZD9w1OApIXmGLhOifoBeTvRk3bqmjy iiqCVzzJ3sMWZ74S79RZDV0vkJANfwDj8odIjz5oE/g497XgsgB1EM0/GrO6OgkhXo9Ihl/7w85cB tjiuGpdA==; Received: from [192.168.2.1] (port=53838 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 1ptaes-000JAS-1Y; Mon, 01 May 2023 22:02:07 +0100 From: Arun Isaac Date: Mon, 1 May 2023 22:01:50 +0100 Message-Id: <20230501210151.16399-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * mumi/client.scm (git-send-email): Add options optional argument. --- mumi/client.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mumi/client.scm b/mumi/client.scm index b8d588b..2750836 100644 --- a/mumi/client.scm +++ b/mumi/client.scm @@ -207,12 +207,13 @@ arguments." (cut proc port) (cut close-pipe port)))))) -(define (git-send-email to patches) - "Send PATCHES using git send-email to the TO address and return the -message ID of the first email sent." +(define* (git-send-email to patches #:optional (options '())) + "Send PATCHES using git send-email to the TO address with +OPTIONS. Return the message ID of the first email sent." (let ((command (cons* "git" "send-email" (string-append "--to=" to) - patches))) + (append options + patches)))) (display (string-join command)) (newline) (call-with-input-pipe command From patchwork Mon May 1 21:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Isaac X-Patchwork-Id: 49732 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DF4B927BBEA; Mon, 1 May 2023 22:03:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F35FD27BBE2 for ; Mon, 1 May 2023 22:03:10 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptafo-0005is-AE; Mon, 01 May 2023 17:03:04 -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 1ptafm-0005ie-Py for guix-patches@gnu.org; Mon, 01 May 2023 17:03:02 -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 1ptafm-00046F-Hw for guix-patches@gnu.org; Mon, 01 May 2023 17:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ptafm-0006a3-BC for guix-patches@gnu.org; Mon, 01 May 2023 17:03:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63215] [PATCH mumi 2/2] client: Cc issue participants when sending email. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 01 May 2023 21:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63215 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63215@debbugs.gnu.org Cc: Arun Isaac Received: via spool by 63215-submit@debbugs.gnu.org id=B63215.168297493525231 (code B ref 63215); Mon, 01 May 2023 21:03:02 +0000 Received: (at 63215) by debbugs.gnu.org; 1 May 2023 21:02:15 +0000 Received: from localhost ([127.0.0.1]:41164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptaf0-0006Yn-W9 for submit@debbugs.gnu.org; Mon, 01 May 2023 17:02:15 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:51320) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ptaey-0006YX-EL for 63215@debbugs.gnu.org; Mon, 01 May 2023 17:02:14 -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=Nm8dSZW8EJdvciuI5IJBU3IRgGDdbQj+KuXBIgho93E=; b=gpPGl9cIweGEHOLiYp+p0VTHpQ s0/5TYjCmxSb2hwovYiD+JqCLfsiRAJgH4qF5iPHn0wo6xLvoq9dSiTdUITx1Ti/IuOacXZ1msYwa NwMCFB5EYNPqo3xPNTfEdCvUktqHb6KhSRYkKSTDBLo3W1osWyeAEWckSbp2Ug2CHzVE17tuEM8jK m9ZT+aPg7f5dZpfe0TK25/fOCdLlfTJ6L+14qZY5dEAiceODA32F1I7PH9i0IJBg5NZ/J2zXMVkvj kc4xN0rzZ3mGngUp5zrNVVUluZl0xKp8V4PZd50Sk/+UAxwSLXxyv1TQqd27WSms41cZYGo4xqRZJ +UTcJnug==; Received: from [192.168.2.1] (port=53838 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 1ptaeu-000JAS-2H; Mon, 01 May 2023 22:02:09 +0100 From: Arun Isaac Date: Mon, 1 May 2023 22:01:51 +0100 Message-Id: <20230501210151.16399-2-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501210151.16399-1-arunisaac@systemreboot.net> References: <20230501210151.16399-1-arunisaac@systemreboot.net> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * mumi/client.scm: Import (srfi srfi-1). (reply-email-headers): New function. (send-email): Call reply-email-headers. * tests/client.scm ("send patches to existing issue", "send single patch to existing issue"): Stub reply-email-headers. ("send patch to existing issue and Cc other participants"): New test. --- mumi/client.scm | 35 +++++++++++++++++++++++++++++++---- tests/client.scm | 24 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/mumi/client.scm b/mumi/client.scm index 2750836..0ad49fc 100644 --- a/mumi/client.scm +++ b/mumi/client.scm @@ -18,6 +18,7 @@ (define-module (mumi client) #:use-module (rnrs io ports) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-26) #:use-module (srfi srfi-43) @@ -236,15 +237,41 @@ OPTIONS. Return the message ID of the first email sent." (display (get-string-all port)) message-id))))) +(define (reply-email-headers issue-number) + "Return an association list of email headers when replying to +ISSUE-NUMBER." + (let ((messages + (assoc-ref + (assoc-ref + (graphql-http-get (graphql-endpoint) + `(document + (query (#(issue #:number ,issue-number) + (messages (from name) + date))))) + "issue") + "messages"))) + ;; When sending email to an issue, we Cc all issue participants. + ;; TODO: Also add an In-Reply-To header. + `((cc . ,(delete-duplicates + (map (lambda (message) + (let ((from (assoc-ref message "from"))) + (string-append (assoc-ref from "name") + " <" (assoc-ref from "address") ">"))) + (vector->list messages))))))) + (define (send-email patches) "Send PATCHES via email." (if (current-issue-number) ;; If an issue is current, send patches to that issue's email ;; address. - (git-send-email (string-append (number->string (current-issue-number)) - "@" - (client-config 'debbugs-host)) - patches) + (let ((issue-number (current-issue-number))) + (git-send-email (string-append (number->string issue-number) + "@" + (client-config 'debbugs-host)) + patches + (map (cut string-append "--cc=" <>) + (assq-ref (reply-email-headers issue-number) + 'cc)))) (match patches ;; If it's a single patch, send it to the patch email address ;; and be done with it diff --git a/tests/client.scm b/tests/client.scm index 94c8c5d..f0ff34e 100644 --- a/tests/client.scm +++ b/tests/client.scm @@ -90,6 +90,8 @@ called with." (lambda () (with-variables (list (cons (var@@ (mumi client) current-issue-number) (const 12345)) + (cons (var@@ (mumi client) reply-email-headers) + (const '((cc)))) client-config-stub do-not-poll-server-for-issue-number) (cut (@@ (mumi client) send-email) @@ -116,6 +118,28 @@ called with." (lambda () (with-variables (list (cons (var@@ (mumi client) current-issue-number) (const 12345)) + (cons (var@@ (mumi client) reply-email-headers) + (const '((cc)))) + client-config-stub + do-not-poll-server-for-issue-number) + (cut (@@ (mumi client) send-email) + (list "foo.patch"))))))) + +(test-equal "send patch to existing issue and Cc other participants" + '(("git" "send-email" + "--to=12345@example.com" + "--cc=John Doe " + "--cc=Mary Smith " + "foo.patch")) + (map (match-lambda + ((command _) command)) + (trace-calls (var@@ (mumi client) call-with-input-pipe) + (lambda () + (with-variables (list (cons (var@@ (mumi client) current-issue-number) + (const 12345)) + (cons (var@@ (mumi client) reply-email-headers) + (const `((cc "John Doe " + "Mary Smith ")))) client-config-stub do-not-poll-server-for-issue-number) (cut (@@ (mumi client) send-email)