unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Arun Isaac <arunisaac@systemreboot.net>
Cc: rekado@elephly.net, 63378@debbugs.gnu.org
Subject: bug#63378: [PATCH] teams: Fix script to produce a single X-Debbugs-Cc header.
Date: Wed, 10 May 2023 12:15:15 -0400	[thread overview]
Message-ID: <87bkisqi24.fsf@gmail.com> (raw)
In-Reply-To: <87jzxh6ovy.fsf@systemreboot.net> (Arun Isaac's message of "Wed,  10 May 2023 00:55:45 +0100")

Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

> Hi Maxim,
>
> When a patch relates to no teams, I get the empty header output
> "X-Debbugs-Cc: ". For such patches, it would be nicer to not add any
> header instead of adding an empty header.

Good catch!  Fixed.

>> +(define (team->members team)
>> +  "Return the list of members in TEAM."
>> +  (sort (team-members team)
>> +        (lambda (m1 m2)
>> +          (string<? (person-name m1) (person-name m2)))))
>> +
>> +(define (member->string member)
>> +  "Return the 'email <name>' string representation of MEMBER."
>> +  (format #false "~a <~a>" (person-name member) (person-email
>> member)))
>
> When person name contains a comma, it should be escaped by surrounding
> in double quotes. Else, the comma would interfere with the
> comma-separated list that we are constructing for
> X-Debbugs-Cc. Admittedly, none of our current team members have commas
> in their person names. But, some people like to have a name like
> "LastName, FirstName". We should protect against that edge case in the
> interest of futureproofing.

OK!  I opted for simplicity and double-quoted all the names.

>> +     (format #true "X-Debbugs-Cc: ~{~a~^,~}"
>> +             (append-map (compose (cut map member->string <>)
>> +                                  team->members
>> +                                  find-team)
>> +                         (patch->teams patch-file))))
>
> A very nitpicky suggestion: Maybe, separate multiple persons by ", "
> instead of just ",". ", " looks slightly better cosmetically. Likewise
> in other places where this occurs.

Good idea; I've learnt this was valid email syntax just today :-).

Below is the diff of my rework:

--8<---------------cut here---------------start------------->8---
1 file changed, 18 insertions(+), 17 deletions(-)
etc/teams.scm.in | 35 ++++++++++++++++++-----------------

modified   etc/teams.scm.in
@@ -605,20 +605,20 @@ (define (find-team-by-scope files)
 (define (cc . teams)
   "Return arguments for `git send-email' to notify the members of the given
 TEAMS when a patch is received by Debbugs."
-  (format #true
-          "--add-header=\"X-Debbugs-Cc: ~{~a~^,~}\""
-          (map person-email
-               (delete-duplicates (append-map team-members teams) equal?))))
-
-(define (team->members team)
-  "Return the list of members in TEAM."
-  (sort (team-members team)
+  (let ((members (append-map team-members teams)))
+    (unless (null? members)
+      (format #true "--add-header=\"X-Debbugs-Cc: ~{~a~^, ~}\""
+              (map person-email (sort-members members))))))
+
+(define (sort-members members)
+  "Deduplicate and sort MEMBERS alphabetically by their name."
+  (sort (delete-duplicates members equal?)
         (lambda (m1 m2)
           (string<? (person-name m1) (person-name m2)))))
 
 (define (member->string member)
   "Return the 'email <name>' string representation of MEMBER."
-  (format #false "~a <~a>" (person-name member) (person-email member)))
+  (format #false "\"~a\" <~a>" (person-name member) (person-email member)))
 
 (define* (list-members team #:optional port (prefix ""))
   "Print the members of the given TEAM."
@@ -626,7 +626,7 @@ (define* (list-members team #:optional port (prefix ""))
   (for-each
    (lambda (member)
      (format port* "~a~a~%" prefix (member->string member)))
-   (team->members team)))
+   (sort-members (team-members team))))
 
 (define (list-teams)
   "Print all teams, their scope and their members."
@@ -720,14 +720,15 @@ (define (main . args)
      (apply cc (find-team-by-scope
                 (diff-revisions rev-start rev-end))))
     (("cc-members-header-cmd" patch-file)
-     (format #true "X-Debbugs-Cc: ~{~a~^,~}"
-             (append-map (compose (cut map member->string <>)
-                                  team->members
-                                  find-team)
-                         (patch->teams patch-file))))
+     (let* ((teams (map find-team (patch->teams patch-file)))
+            (members (sort-members (append-map team-members teams))))
+       (unless (null? members)
+         (format #true "X-Debbugs-Cc: ~{~a~^, ~}"
+                 (map member->string members)))))
     (("cc-mentors-header-cmd" patch-file)
-     (format #true "X-Debbugs-Cc: ~{~a~^,~}"
-             (map member->string (team->members (find-team "mentors")))))
+     (format #true "X-Debbugs-Cc: ~{~a~^, ~}"
+             (map member->string
+                  (sort-members (team-members (find-team "mentors"))))))
     (("get-maintainer" patch-file)
      (apply main "list-members" (patch->teams patch-file)))
     (("list-teams" . args)
--8<---------------cut here---------------end--------------->8---

A proper v2 patch has been sent.

-- 
Thanks,
Maxim




  reply	other threads:[~2023-05-10 16:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08 17:17 bug#63378: A single X-Debbugs-CC header must be used Maxim Cournoyer
2023-05-08 18:29 ` bug#63378: [PATCH] teams: Fix script to produce a single X-Debbugs-Cc header Maxim Cournoyer
2023-05-09 13:33   ` bug#63378: A single X-Debbugs-CC header must be used Maxim Cournoyer
2023-05-09 23:43     ` Arun Isaac
2023-05-10  1:15       ` Maxim Cournoyer
2023-05-09 23:55   ` bug#63378: [PATCH] teams: Fix script to produce a single X-Debbugs-Cc header Arun Isaac
2023-05-10 16:15     ` Maxim Cournoyer [this message]
2023-05-11 11:13       ` Arun Isaac
2023-05-11 13:18         ` Maxim Cournoyer
2023-05-11 23:59           ` Arun Isaac
2023-05-10  2:55 ` bug#63378: [PATCH v2] " Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkisqi24.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=63378@debbugs.gnu.org \
    --cc=arunisaac@systemreboot.net \
    --cc=rekado@elephly.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).