[PATCH mumi 0/2] Cc all issue participants when sending email

  • Done
  • quality assurance status badge
Details
3 participants
  • Arun Isaac
  • Felix Lechner
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Arun Isaac
Severity
normal
A
A
Arun Isaac wrote on 1 May 2023 22:56
(address . guix-patches@gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230501205639.16201-1-arunisaac@systemreboot.net
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
A
A
Arun Isaac wrote on 1 May 2023 23:01
[PATCH mumi 1/2] client: Support passing options to git send-email.
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230501210151.16399-1-arunisaac@systemreboot.net
* mumi/client.scm (git-send-email): Add options optional argument.
---
mumi/client.scm | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Toggle diff (24 lines)
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
A
A
Arun Isaac wrote on 1 May 2023 23:01
[PATCH mumi 2/2] client: Cc issue participants when sending email.
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230501210151.16399-2-arunisaac@systemreboot.net
* 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(-)

Toggle diff (102 lines)
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 <jdoe@machine.example>"
+ "--cc=Mary Smith <mary@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@machine.example>"
+ "Mary Smith <mary@example.net>"))))
client-config-stub
do-not-poll-server-for-issue-number)
(cut (@@ (mumi client) send-email)
--
2.39.2
A
A
Arun Isaac wrote on 2 May 2023 00:51
[PATCH v2 mumi 0/2] Cc all issue participants
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230501225158.18612-1-arunisaac@systemreboot.net
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
A
A
Arun Isaac wrote on 2 May 2023 00:51
[PATCH v2 mumi 1/2] client: Support passing options to git send-email.
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230501225158.18612-2-arunisaac@systemreboot.net
* mumi/client.scm (git-send-email): Add options optional argument.
---
mumi/client.scm | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Toggle diff (24 lines)
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
A
A
Arun Isaac wrote on 2 May 2023 00:51
[PATCH v2 mumi 2/2] client: Cc issue participants when sending email.
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230501225158.18612-3-arunisaac@systemreboot.net
* 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(-)

Toggle diff (102 lines)
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@example.com"
+ "--cc=John Doe <jdoe@machine.example>"
+ "--cc=Mary Smith <mary@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@machine.example>"
+ "Mary Smith <mary@example.net>"))))
client-config-stub
do-not-poll-server-for-issue-number)
(cut (@@ (mumi client) send-email)
--
2.39.2
M
M
Maxim Cournoyer wrote on 3 May 2023 04:39
Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when sending email
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 63215@debbugs.gnu.org)
87y1m6yw80.fsf_-_@gmail.com
Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (7 lines)
> * 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!

Toggle quote (61 lines)
> ---
> 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
A
A
Arun Isaac wrote on 5 May 2023 04:00
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 63215@debbugs.gnu.org)
87jzxnbkqt.fsf@systemreboot.net
Hi Maxim,

Toggle quote (12 lines)
> 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
A
A
Arun Isaac wrote on 5 May 2023 15:24
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 63215@debbugs.gnu.org)
87a5yic3mw.fsf@systemreboot.net
Toggle quote (6 lines)
> 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?
M
M
Maxim Cournoyer wrote on 5 May 2023 18:18
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 63215@debbugs.gnu.org)
871qju4urk.fsf@gmail.com
Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (14 lines)
>> 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).


--
Thanks,
Maxim
A
A
Arun Isaac wrote on 7 May 2023 00:30
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 63215@debbugs.gnu.org)
87zg6h9jph.fsf@systemreboot.net
Hi Maxim,

Toggle quote (5 lines)
> 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.

Toggle quote (7 lines)
> 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.

Toggle quote (12 lines)
> 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
A
A
Arun Isaac wrote on 7 May 2023 00:35
[PATCH 1/2] client: Support passing options to git send-email.
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230506223520.27933-1-arunisaac@systemreboot.net
* mumi/client.scm (git-send-email): Add options optional argument.
---
mumi/client.scm | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

Toggle diff (24 lines)
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
A
A
Arun Isaac wrote on 7 May 2023 00:35
[PATCH 2/2] client: Cc issue participants when sending email.
(address . 63215@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20230506223520.27933-2-arunisaac@systemreboot.net
* 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(-)

Toggle diff (104 lines)
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@example.com"
+ "--add-header=X-Debbugs-Cc: John Doe <jdoe@machine.example>"
+ "--add-header=X-Debbugs-Cc: Mary Smith <mary@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@machine.example>"
+ "Mary Smith <mary@example.net>"))))
client-config-stub
do-not-poll-server-for-issue-number)
(cut (@@ (mumi client) send-email)
--
2.39.2
M
M
Maxim Cournoyer wrote on 7 May 2023 04:27
Re: bug#63215: [PATCH mumi 0/2] Cc all issue participants when sending email
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 63215@debbugs.gnu.org)
87o7mw3mg8.fsf@gmail.com
Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (21 lines)
> 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.

Toggle quote (4 lines)
> 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
A
A
Arun Isaac wrote on 7 May 2023 13:27
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 63215-done@debbugs.gnu.org)
87mt2g9yaf.fsf@systemreboot.net
Toggle quote (3 lines)
> 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.

Toggle quote (6 lines)
>> 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!
Closed
F
F
Felix Lechner wrote on 8 Feb 18:25 +0100
(no subject)
(address . control@debbugs.gnu.org)
87plx66f7u.fsf@lease-up.com
unarchive 49115
reassign 49115 mumi
archive 49115

unarchive 41906
reassign 41906 mumi
archive 41906

unarchive 60410
reassign 60410 mumi
archive 60410

unarchive 63215
reassign 63215 mumi
archive 63215

unarchive 41098
reassign 41098 mumi
archive 41098

thanks
F
F
Felix Lechner wrote on 23 Feb 14:23 +0100
(address . control@debbugs.gnu.org)
875xyf1fhb.fsf@lease-up.com
unarchive 68680
reassign 68680 mumi
archive 68680

unarchive 63802
reassign 63802 mumi
archive 63802

unarchive 63215
reassign 63215 mumi
archive 63215

unarchive 61645
reassign 61645 mumi
archive 61645

unarchive 60410
reassign 60410 mumi
archive 60410

unarchive 60292
reassign 60292 mumi
archive 60292

unarchive 60292
reassign 60292 mumi
archive 60292

unarchive 58573
reassign 58573 mumi
archive 58573

unarchive 54024
reassign 54024 mumi
archive 54024

unarchive 49115
reassign 49115 mumi
archive 49115

unarchive 48160
reassign 48160 mumi
archive 48160

unarchive 47739
reassign 47739 mumi
archive 47739

unarchive 47520
reassign 47520 mumi
archive 47520

unarchive 47121
reassign 47121 mumi
archive 47121

unarchive 45015
reassign 45015 mumi
archive 45015

unarchive 43661
reassign 43661 mumi
archive 43661

unarchiv 43166
reassign 43166 mumi
archive 43166

unarchive 41906
reassign 41906 mumi
archive 41906

unarchive 41098
reassign 41098 mumi
archive 41098

unarchive 39924
reassign 39924 mumi
archive 39924

unarchive 39924
reassign 39924 mumi
archive 39924

unarchive 39924
reassign 39924 mumi
archive 39924

thanks
?
Your comment

This issue is archived.

To comment on this conversation send an email to 63215@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 63215
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch