From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id yGwxElXDW2R/tQAASxT56A (envelope-from ) for ; Wed, 10 May 2023 18:16:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id qNplElXDW2Q2TwAAauVa8A (envelope-from ) for ; Wed, 10 May 2023 18:16:21 +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 D87EECB7C for ; Wed, 10 May 2023 18:16:20 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwmU0-0005DB-M7; Wed, 10 May 2023 12:16: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 1pwmTy-0005CW-Te for bug-guix@gnu.org; Wed, 10 May 2023 12:16: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 1pwmTy-0001Mi-LD for bug-guix@gnu.org; Wed, 10 May 2023 12:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pwmTy-0002jT-6h for bug-guix@gnu.org; Wed, 10 May 2023 12:16:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#63378: [PATCH] teams: Fix script to produce a single X-Debbugs-Cc header. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 10 May 2023 16:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63378 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Arun Isaac Cc: rekado@elephly.net, 63378@debbugs.gnu.org Received: via spool by 63378-submit@debbugs.gnu.org id=B63378.168373532710455 (code B ref 63378); Wed, 10 May 2023 16:16:02 +0000 Received: (at 63378) by debbugs.gnu.org; 10 May 2023 16:15:27 +0000 Received: from localhost ([127.0.0.1]:48801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwmTO-0002iZ-V3 for submit@debbugs.gnu.org; Wed, 10 May 2023 12:15:27 -0400 Received: from mail-qt1-f170.google.com ([209.85.160.170]:55712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwmTK-0002iF-PU for 63378@debbugs.gnu.org; Wed, 10 May 2023 12:15:26 -0400 Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-3f3faefc92cso10070121cf.3 for <63378@debbugs.gnu.org>; Wed, 10 May 2023 09:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683735317; x=1686327317; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qwJ5iIUYSkIObvKxejnLsl58C6WAvwbk+ZNPBx1ywWo=; b=VyO5+UNM4o+Wn8Q7ZM5Oev5tLabgPbej+cHvdYtvpvgLeUhqwjq2l37pfwqYGsWvQX IDhvlG7WSWDnFq03O2GWhsHfvHqlsuxV0Uefrlm3kgYWksYy+2CjAGxcyhjrugnCZfOp cSUXd+4krqB7ZlhcOoHG8viWaMLkaesB5OFiY3F3fVkv4wmfCWmH+9OrCCjt1s1qnd/N +RW3/5tkVrgErdY1ESLWIoJL5HB8L5WLxY3mpLphodxJ5l2pq3+MmGNErO/q5ylvp5u2 UAAnTrCQzNQyVQExAySR4nl/RaRTsK8bYmcVJeJI4CzxFyjmedsU2Fl0FDvcVAi7F5GK zkQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683735317; x=1686327317; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qwJ5iIUYSkIObvKxejnLsl58C6WAvwbk+ZNPBx1ywWo=; b=ADrCZqOZmzQs85ZI04paDzqrhBq0lxWpnUTDGi/Aoj5y16rIQc2NLfEji4CvRqR873 4Tr/SgHaaXH/ubua/QbNcTABXjTvdQjGG5EqcxTw1d3oUOBExXW5ho1Mr3VY+0C/e5cR 0v758qAPWHbYSYe0Ij5mjrrvH/FPkUaSDkF81lubbMiMPjlowYEJw4etIIuNVHkgDG/+ imhuOTwoPBmscaCCMAAr9kcFDENjqAmJ8n+ZXqkF6XWo0KytTCw9QWDesBJfZCO05XNZ 7kfPuowNY6ODUIDipUq3yjuULG3yJnk4rG8F8NdLi/HXBFYCc6MNAyCTD8Ysv+XuIx+U epNw== X-Gm-Message-State: AC+VfDyyb1CCvbXAZ1NKHSypI/sd0S0B24yWMpKon/bU/wNfpnpcGMb1 rlF1H91leHL9hA3vj0BW3KVebHQmqWMAZA== X-Google-Smtp-Source: ACHHUZ60mnnDB4sO/GLasP+bck95e/dJ+wSEL3V+GJqF6diJEU1LZkRNOHkhsTJvnbcREy/8tzavxg== X-Received: by 2002:a05:622a:11c9:b0:3f0:a300:a471 with SMTP id n9-20020a05622a11c900b003f0a300a471mr27369427qtk.55.1683735317151; Wed, 10 May 2023 09:15:17 -0700 (PDT) Received: from hurd (dsl-156-94.b2b2c.ca. [66.158.156.94]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a01e100b0074b5219b63esm1036623qkn.121.2023.05.10.09.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 09:15:16 -0700 (PDT) From: Maxim Cournoyer References: <875y92vj2j.fsf@gmail.com> <3e14e27ad26ce9dee230733c7e77935b5f43599d.1683570582.git.maxim.cournoyer@gmail.com> <87jzxh6ovy.fsf@systemreboot.net> Date: Wed, 10 May 2023 12:15:15 -0400 In-Reply-To: <87jzxh6ovy.fsf@systemreboot.net> (Arun Isaac's message of "Wed, 10 May 2023 00:55:45 +0100") Message-ID: <87bkisqi24.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683735381; a=rsa-sha256; cv=none; b=tZdQsnQANjadaJyI1pkmZM4PVJ/dABy0Sl0x8RQ6JZZNki2oSRTP8kMrUNvDYbB+FgmpZE J5/CoMHwskQbdxW160suex/yKvhUJTa0rrK0zFZPb8NFmnq7nimVkoMEw7gRIEOy0TG8B7 7ngfebhrfKJMycYiXeelzeCa8YivOixJMnIQ+uPT0zbxc9uEfJFrJ/Uj/QdTCCnYEzsK9m yzCQf37kUvrq2Ol3l9kPWjJSgGIrsDP/CeoonHedWaCuCe2emq1JsGn9nBffCYzeUj6wQS CmfPSrM9+vuajabhtjH8HPTTiFhLAr7LlntrrrfEVf5JBsDBuTyllUmJWbA+tg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=VyO5+UNM; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683735381; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: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=qwJ5iIUYSkIObvKxejnLsl58C6WAvwbk+ZNPBx1ywWo=; b=cu2I0xhuQBW6Q2h6CDuovnK203TzW+SX4+rgnQnRk96E5GRdc+DS1ofJerBTLsJGKw4JFg JUTrTg01C0AhCiJTNS+HTkliapvu8PYfAhYfyafgc90XbH5iC5rE1rCAjkB96f/XBVsN5n gUB+ByU+KydTE014Nm9OGWURSh3xC0kjsmwteoCvPXrWzxvxV88YRa3WnpAJoTUMft9gSd Uks0Su5ut6ix6YSjMI3TrdxuvaSzMbj/J/rrTBIi2ToRoNXFqOajqqvO3dqbiy+Q0LMOi/ HqATC8B4dcW7q0CESN3UNsSZvW8NmDMRmAU9hHHxymfijLB+lJwISN7nJAnfXg== X-Migadu-Spam-Score: -2.38 X-Spam-Score: -2.38 X-Migadu-Queue-Id: D87EECB7C X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=VyO5+UNM; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-TUID: 2uGaPJrPVeSn Hi Arun, Arun Isaac 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> + >> +(define (member->string member) >> + "Return the 'email ' 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) (stringstring member) "Return the 'email ' 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