GNU bug report logs - #63215
[PATCH mumi 0/2] Cc all issue participants when sending email

Previous Next

Package: mumi;

Reported by: Arun Isaac <arunisaac <at> systemreboot.net>

Date: Mon, 1 May 2023 20:58:02 UTC

Severity: normal

Tags: patch

Done: Arun Isaac <arunisaac <at> systemreboot.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63215 in the body.
You can then email your comments to 63215 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Mon, 01 May 2023 20:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arun Isaac <arunisaac <at> systemreboot.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 01 May 2023 20:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: guix-patches <at> gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH mumi 0/2] Cc all issue participants when sending email
Date: Mon,  1 May 2023 21:56:39 +0100
Hi,

This patchset makes mumi send-email automatically Cc all issue
participants. I will push this patchset in a few days unless there are
objections.

Cheers!
Arun

Arun Isaac (2):
  client: Support passing options to git send-email.
  client: Cc issue participants when sending email.

 mumi/client.scm  | 44 ++++++++++++++++++++++++++++++++++++--------
 tests/client.scm | 24 ++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 8 deletions(-)

-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Mon, 01 May 2023 21:03:01 GMT) Full text and rfc822 format available.

Message #8 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH mumi 1/2] client: Support passing options to git send-email.
Date: Mon,  1 May 2023 22:01:50 +0100
* 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
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Mon, 01 May 2023 21:03:02 GMT) Full text and rfc822 format available.

Message #11 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH mumi 2/2] client: Cc issue participants when sending email.
Date: Mon,  1 May 2023 22:01:51 +0100
* 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 <at> example.com"
+     "--cc=John Doe <jdoe <at> machine.example>"
+     "--cc=Mary Smith <mary <at> example.net>"
+     "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 <jdoe <at> machine.example>"
+                                                    "Mary Smith <mary <at> example.net>"))))
                                  client-config-stub
                                  do-not-poll-server-for-issue-number)
              (cut (@@ (mumi client) send-email)
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Mon, 01 May 2023 22:53:01 GMT) Full text and rfc822 format available.

Message #14 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH v2 mumi 0/2] Cc all issue participants
Date: Mon,  1 May 2023 23:51:56 +0100
I have fixed a bug in the v1 patchset with fetching participants'
addresses. Please consider this v2 patchset instead.

Arun Isaac (2):
  client: Support passing options to git send-email.
  client: Cc issue participants when sending email.

 mumi/client.scm  | 44 ++++++++++++++++++++++++++++++++++++--------
 tests/client.scm | 24 ++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 8 deletions(-)

-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Mon, 01 May 2023 22:53:02 GMT) Full text and rfc822 format available.

Message #17 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH v2 mumi 1/2] client: Support passing options to git send-email.
Date: Mon,  1 May 2023 23:51:57 +0100
* 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
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Mon, 01 May 2023 22:53:02 GMT) Full text and rfc822 format available.

Message #20 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH v2 mumi 2/2] client: Cc issue participants when sending email.
Date: Mon,  1 May 2023 23:51:58 +0100
* 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..f0e4321 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 address)
+                                                 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 <at> example.com"
+     "--cc=John Doe <jdoe <at> machine.example>"
+     "--cc=Mary Smith <mary <at> example.net>"
+     "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 <jdoe <at> machine.example>"
+                                                    "Mary Smith <mary <at> example.net>"))))
                                  client-config-stub
                                  do-not-poll-server-for-issue-number)
              (cut (@@ (mumi client) send-email)
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Wed, 03 May 2023 02:40:02 GMT) Full text and rfc822 format available.

Message #23 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 63215 <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Tue, 02 May 2023 22:39:27 -0400
Hi Arun,

Arun Isaac <arunisaac <at> systemreboot.net> writes:

> * 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.

Great series!

> ---
>  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..f0e4321 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 address)
> +                                                 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))))

I was thinking looking at this, with X-Debbugs-Cc headers now being
added automatically by Git for members of a team, there could be
duplication between X-Debbugs-Cc and the participannts retrieved from
the messages above.

To ensure participants do not receive duplicate replies, it'd be
probably best to stick to using X-Debbugs-Cc with all interactions with
Debbugs; this way a duplicate header is (hopefully) ignored by Debbugs
itself.

Does that make sense?

-- 
Thanks,
Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Fri, 05 May 2023 02:01:02 GMT) Full text and rfc822 format available.

Message #26 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 63215 <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Fri, 05 May 2023 03:00:26 +0100
Hi Maxim,

> I was thinking looking at this, with X-Debbugs-Cc headers now being
> added automatically by Git for members of a team, there could be
> duplication between X-Debbugs-Cc and the participannts retrieved from
> the messages above.
>
> To ensure participants do not receive duplicate replies, it'd be
> probably best to stick to using X-Debbugs-Cc with all interactions with
> Debbugs; this way a duplicate header is (hopefully) ignored by Debbugs
> itself.
>
> Does that make sense?

Yes, that makes sense! I will send a new patchset. According to
https://www.debian.org/Bugs/Reporting#xcc , if we want to send copies to
multiple addresses, we should put them in as a comma-separated list in
the same X-Debbugs-Cc header. teams.scm seems to be putting in multiple
X-Debbugs-Cc headers. Maybe we should change that?

I see mumi as being more widely usable than just for Guix. For example,
I wish to use it for skribilo, another Guile project that uses the
Debbugs issue tracker. So, in the future, if and when applicable, we
might want to move some of teams.scm's functionality into `mumi
send-email'.

Regards,
Arun




Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Fri, 05 May 2023 13:25:01 GMT) Full text and rfc822 format available.

Message #29 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 63215 <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Fri, 05 May 2023 14:24:39 +0100
> Yes, that makes sense! I will send a new patchset. According to
> https://www.debian.org/Bugs/Reporting#xcc , if we want to send copies to
> multiple addresses, we should put them in as a comma-separated list in
> the same X-Debbugs-Cc header. teams.scm seems to be putting in multiple
> X-Debbugs-Cc headers. Maybe we should change that?

I just realized that using comma-separated lists calls for the
functionality of teams.scm to be moved into `mumi send-email'. If
teams.scm and `mumi send-email' remain separate, they will each produce
a separate comma-separated list of X-Debbugs-Cc addresses, and we will
be back to square one with multiple X-Debbugs-Cc headers.

WDYT? What is the best way forward?




Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Fri, 05 May 2023 16:19:02 GMT) Full text and rfc822 format available.

Message #32 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 63215 <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Fri, 05 May 2023 12:18:07 -0400
Hi Arun,

Arun Isaac <arunisaac <at> systemreboot.net> writes:

>> Yes, that makes sense! I will send a new patchset. According to
>> https://www.debian.org/Bugs/Reporting#xcc , if we want to send copies to
>> multiple addresses, we should put them in as a comma-separated list in
>> the same X-Debbugs-Cc header. teams.scm seems to be putting in multiple
>> X-Debbugs-Cc headers. Maybe we should change that?
>
> I just realized that using comma-separated lists calls for the
> functionality of teams.scm to be moved into `mumi send-email'. If
> teams.scm and `mumi send-email' remain separate, they will each produce
> a separate comma-separated list of X-Debbugs-Cc addresses, and we will
> be back to square one with multiple X-Debbugs-Cc headers.
>
> WDYT? What is the best way forward?

If you meant that it's mumi instead of git that should call
etc/teams.scm, it makes sense.  I'm not sure the functionality of
teams.scm proper should be moved wholesale into mumi, as it's useful
outside of mumi (for plain git users, say).

Mumi could invoke etc/teams.scm to produce the list of team members for
the changes involved, add any missing collaborators retrieved from the
message data to the set (avoiding duplicates), then format the
'X-Debbugs-CC' header with comma-separated values.  It should then
invoke git with the '--no-header-cmd' option to avoid teams.scm being
called again.

Note that our teams.scm script currently generate distinct X-Debbugs-CC
header for each participant.  The Debbugs copy used by GNU is the one
hosted at [0], which doesn't mention the comma-separated
requirement/suggestion, so I think that's currently OK, although I'm not
too confident in my reading of the 'process' Perl script [1].  At any
rate it'd be easy to adjust in teams.scm.

The email specification mentions that some special fields such as To and
Cc should be separated by commas, but says nothing about custom fields [2],
so in my opinion both forms should be supported by Debbugs (and probably
are, although it's hard to say without trying).

[0]  https://gitlab.com/npostavs/debbugs/-/tree/gnu-reconstruction?ref_type=heads
[1]  https://gitlab.com/npostavs/debbugs/-/blob/gnu-reconstruction/scripts/process 
[2]  https://datatracker.ietf.org/doc/html/rfc5322#section-3.6

-- 
Thanks,
Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Sat, 06 May 2023 22:31:01 GMT) Full text and rfc822 format available.

Message #35 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 63215 <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Sat, 06 May 2023 23:30:18 +0100
Hi Maxim,

> If you meant that it's mumi instead of git that should call
> etc/teams.scm, it makes sense.  I'm not sure the functionality of
> teams.scm proper should be moved wholesale into mumi, as it's useful
> outside of mumi (for plain git users, say).

I see your point about keeping things working for plain git users. Makes
sense.

> Mumi could invoke etc/teams.scm to produce the list of team members for
> the changes involved, add any missing collaborators retrieved from the
> message data to the set (avoiding duplicates), then format the
> 'X-Debbugs-CC' header with comma-separated values.  It should then
> invoke git with the '--no-header-cmd' option to avoid teams.scm being
> called again.

mumi invoking etc/teams.scm is not so nice since that means coupling
mumi to the specific repository layout of guix. This reduces its
generality to other projects, say skribilo.

Maybe, let's just keep multiple X-Debbugs-Cc headers for now. Let mumi
and teams.scm be unaware of each other for now. We can revisit the
question of coupling them later.

> Note that our teams.scm script currently generate distinct X-Debbugs-CC
> header for each participant.  The Debbugs copy used by GNU is the one
> hosted at [0], which doesn't mention the comma-separated
> requirement/suggestion, so I think that's currently OK, although I'm not
> too confident in my reading of the 'process' Perl script [1].  At any
> rate it'd be easy to adjust in teams.scm.
>
> The email specification mentions that some special fields such as To and
> Cc should be separated by commas, but says nothing about custom fields [2],
> so in my opinion both forms should be supported by Debbugs (and probably
> are, although it's hard to say without trying).

Fair enough. Let's keep multiple X-Debbugs-Cc headers and hope for the
best! :-) A new patchset follows. The only difference between this
patchset and the previous one is that we set X-Debbugs-Cc headers
instead of Cc headers.

Regards,
Arun




Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Sat, 06 May 2023 22:36:02 GMT) Full text and rfc822 format available.

Message #38 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH 1/2] client: Support passing options to git send-email.
Date: Sat,  6 May 2023 23:35:19 +0100
* 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
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Sat, 06 May 2023 22:36:02 GMT) Full text and rfc822 format available.

Message #41 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 63215 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH 2/2] client: Cc issue participants when sending email.
Date: Sat,  6 May 2023 23:35:20 +0100
* 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  | 36 ++++++++++++++++++++++++++++++++----
 tests/client.scm | 25 +++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/mumi/client.scm b/mumi/client.scm
index 2750836..7ba47e6 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,42 @@ 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 address)
+                                                 date)))))
+           "issue")
+          "messages")))
+    ;; When sending email to an issue, we Cc all issue participants.
+    ;; TODO: Also add an In-Reply-To header.
+    `((x-debbugs-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 "--add-header=X-Debbugs-Cc: " <>)
+                             (assq-ref (reply-email-headers issue-number)
+                                       'x-debbugs-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..1d40c10 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 '((x-debbugs-cc))))
                                  client-config-stub
                                  do-not-poll-server-for-issue-number)
              (cut (@@ (mumi client) send-email)
@@ -116,6 +118,29 @@ called with."
          (lambda ()
            (with-variables (list (cons (var@@ (mumi client) current-issue-number)
                                        (const 12345))
+                                 (cons (var@@ (mumi client) reply-email-headers)
+                                       (const '((x-debbugs-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 <at> example.com"
+     "--add-header=X-Debbugs-Cc: John Doe <jdoe <at> machine.example>"
+     "--add-header=X-Debbugs-Cc: Mary Smith <mary <at> example.net>"
+     "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 `((x-debbugs-cc
+                                                 "John Doe <jdoe <at> machine.example>"
+                                                 "Mary Smith <mary <at> example.net>"))))
                                  client-config-stub
                                  do-not-poll-server-for-issue-number)
              (cut (@@ (mumi client) send-email)
-- 
2.39.2





Information forwarded to guix-patches <at> gnu.org:
bug#63215; Package guix-patches. (Sun, 07 May 2023 02:28:02 GMT) Full text and rfc822 format available.

Message #44 received at 63215 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: 63215 <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Sat, 06 May 2023 22:27:35 -0400
Hi Arun,

Arun Isaac <arunisaac <at> systemreboot.net> writes:

> Hi Maxim,
>
>> If you meant that it's mumi instead of git that should call
>> etc/teams.scm, it makes sense.  I'm not sure the functionality of
>> teams.scm proper should be moved wholesale into mumi, as it's useful
>> outside of mumi (for plain git users, say).
>
> I see your point about keeping things working for plain git users. Makes
> sense.
>
>> Mumi could invoke etc/teams.scm to produce the list of team members for
>> the changes involved, add any missing collaborators retrieved from the
>> message data to the set (avoiding duplicates), then format the
>> 'X-Debbugs-CC' header with comma-separated values.  It should then
>> invoke git with the '--no-header-cmd' option to avoid teams.scm being
>> called again.
>
> mumi invoking etc/teams.scm is not so nice since that means coupling
> mumi to the specific repository layout of guix. This reduces its
> generality to other projects, say skribilo.

Perhaps it could use the value of `git config sendemail.headerCmd` to
figure out which script already produces X-Debbugs-CC headers, if any.

> Maybe, let's just keep multiple X-Debbugs-Cc headers for now. Let mumi
> and teams.scm be unaware of each other for now. We can revisit the
> question of coupling them later.

OK, sounds good to me.

-- 
Thanks,
Maxim




Reply sent to Arun Isaac <arunisaac <at> systemreboot.net>:
You have taken responsibility. (Sun, 07 May 2023 11:29:02 GMT) Full text and rfc822 format available.

Notification sent to Arun Isaac <arunisaac <at> systemreboot.net>:
bug acknowledged by developer. (Sun, 07 May 2023 11:29:02 GMT) Full text and rfc822 format available.

Message #49 received at 63215-done <at> debbugs.gnu.org (full text, mbox):

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 63215-done <at> debbugs.gnu.org
Subject: Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when
 sending email
Date: Sun, 07 May 2023 12:27:36 +0100
> Perhaps it could use the value of `git config sendemail.headerCmd` to
> figure out which script already produces X-Debbugs-CC headers, if any.

That's a good idea! We can revisit this later.

>> Maybe, let's just keep multiple X-Debbugs-Cc headers for now. Let mumi
>> and teams.scm be unaware of each other for now. We can revisit the
>> question of coupling them later.
>
> OK, sounds good to me.

Pushed, thanks!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 05 Jun 2023 11:24:07 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Felix Lechner <felix.lechner <at> lease-up.com> to control <at> debbugs.gnu.org. (Thu, 08 Feb 2024 17:26:03 GMT) Full text and rfc822 format available.

bug reassigned from package 'guix-patches' to 'mumi'. Request was from Felix Lechner <felix.lechner <at> lease-up.com> to control <at> debbugs.gnu.org. (Thu, 08 Feb 2024 17:26:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Felix Lechner <felix.lechner <at> lease-up.com> to control <at> debbugs.gnu.org. (Thu, 08 Feb 2024 17:26:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Felix Lechner <felix.lechner <at> lease-up.com> to control <at> debbugs.gnu.org. (Fri, 23 Feb 2024 13:25:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Felix Lechner <felix.lechner <at> lease-up.com> to control <at> debbugs.gnu.org. (Fri, 23 Feb 2024 13:25:02 GMT) Full text and rfc822 format available.

This bug report was last modified 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.