GNU bug report logs - #78354
[PATCH] teams: Add “codeowners” action.

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sat, 10 May 2025 15:19:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 78354 AT debbugs.gnu.org.

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

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


Report forwarded to gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org:
bug#78354; Package guix-patches. (Sat, 10 May 2025 15:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to gabriel <at> erlikon.ch, ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org. (Sat, 10 May 2025 15:19:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH] teams: Add “codeowners” action.
Date: Sat, 10 May 2025 17:17:38 +0200
* etc/teams.scm (team->codeowners-snippet, export-codeowners): New
procedures.
(main): Add “codeowners” action.
* doc/contributing.texi (Teams): Document it.

Change-Id: I601443981af374d85160833f7096d8c973873fb1
---
 doc/contributing.texi |  7 +++++++
 etc/teams.scm         | 31 +++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

Hello,

This patch enhances ‘etc/teams.scm’ so it can generate a ‘CODEOWNERS’
file.  Forgejo can read that file to direct reviews to the right people.

The result here is a 357-line file, which looks like this:

--8<---------------cut here---------------start------------->8---
gnu/packages/audio\.scm                            @guix/audio

gnu/packages/commencement\.scm                     @guix/bootstrap
gnu/packages/mes\.scm                              @guix/bootstrap

gnu/build-system/cmake\.scm                        @guix/c++
gnu/build/cmake-build-system\.scm                  @guix/c++
gnu/packages/c\.scm                                @guix/c++
gnu/packages/cmake\.scm                            @guix/c++
gnu/packages/cpp\.scm                              @guix/c++
gnu/packages/ninja\.scm                            @guix/c++
gnu/packages/valgrind\.scm                         @guix/c++
--8<---------------cut here---------------end--------------->8---

Of course we’ll have to create those teams on Codeberg so it can
be on any use.

Ludo’.

diff --git a/doc/contributing.texi b/doc/contributing.texi
index f62939dc44..e98407edfd 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -2733,6 +2733,13 @@ Teams
 [env]$ git send-email --to=@var{ISSUE_NUMBER}@@debbugs.gnu.org -2
 @end example
 
+To generate a @file{CODEOWNERS} file, which Forgejo uses to determine
+which team or person should review changes to a given set of files, run:
+
+@example
+./etc/teams.scm codeowners > CODEOWNERS
+@end example
+
 @node Making Decisions
 @section Making Decisions
 
diff --git a/etc/teams.scm b/etc/teams.scm
index 17b5d4d1fe..5d5e104a48 100755
--- a/etc/teams.scm
+++ b/etc/teams.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2022 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2025 Jelle Licht <jlicht <at> fsfe.org>
 ;;; Copyright © 2025 Cayetano Santos <csantosb <at> inventati.org>
+;;; Copyright © 2025 Ludovic Courtès <ludo <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1016,6 +1017,34 @@ (define (patch->teams patch-file)
        (find-team-by-scope (apply diff-revisions
                                   (git-patch->revisions patch-file)))))
 
+(define (team->codeowners-snippet team)
+  (string-join (map (lambda (scope)
+                      (format #f "~50a @guix/~a"
+                              (if (regexp*? scope)
+                                  (regexp*-pattern scope)
+                                  (regexp-quote scope))
+                              (team-id team)))
+                    (team-scope team))
+               "\n"
+               'suffix))
+
+(define (export-codeowners port)
+  (let ((teams (sort-teams
+                (hash-map->list (lambda (_ value) value) %teams))))
+    (display "\
+# This -*- conf -*- file was generated by './etc/teams.scm codeowners'.
+#
+# It describes the expected reviewers for a pull request based on the
+# changed files.  Unlike what the name of the file suggests they don't
+# own the code (ownership is collective in this house!) but merely have
+# a good understanding of that area of the codebase and therefore are
+# usually suited as a reviewer.\n\n"
+             port)
+    (for-each (lambda (team)
+                (display (team->codeowners-snippet team) port)
+                (newline port))
+              teams)))
+
 
 (define (main . args)
   (match args
@@ -1049,6 +1078,8 @@ (define (main . args)
       team-names))
     (("show" . team-names)
      (list-teams team-names))
+    (("codeowners")
+     (export-codeowners (current-output-port)))
     (anything
      (format (current-error-port)
              "Usage: etc/teams.scm <command> [<args>]

base-commit: 2e1ead7c8b449b58d571d8f16c1586b675c13ab4
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#78354; Package guix-patches. (Sun, 11 May 2025 12:50:01 GMT) Full text and rfc822 format available.

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

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 78354 <at> debbugs.gnu.org, Gabriel Wicki <gabriel <at> erlikon.ch>
Subject: Re: [bug#78354] [PATCH] teams: Add “codeowners” action.
Date: Sun, 11 May 2025 21:48:57 +0900
Hi,

Ludovic Courtès <ludo <at> gnu.org> writes:

> * etc/teams.scm (team->codeowners-snippet, export-codeowners): New
> procedures.
> (main): Add “codeowners” action.
> * doc/contributing.texi (Teams): Document it.
>
> Change-Id: I601443981af374d85160833f7096d8c973873fb1

Glad to see some use can be salvaged from etc/teams.scm.  LGTM!

Reviewed-by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

-- 
Thanks,
Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#78354; Package guix-patches. (Sun, 11 May 2025 16:32:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 78354 <at> debbugs.gnu.org, Gabriel Wicki <gabriel <at> erlikon.ch>
Subject: Re: [bug#78354] [PATCH] teams: Add “codeowners” action.
Date: Sun, 11 May 2025 17:05:36 +0200
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> Ludovic Courtès <ludo <at> gnu.org> writes:
>
>> * etc/teams.scm (team->codeowners-snippet, export-codeowners): New
>> procedures.
>> (main): Add “codeowners” action.
>> * doc/contributing.texi (Teams): Document it.
>>
>> Change-Id: I601443981af374d85160833f7096d8c973873fb1
>
> Glad to see some use can be salvaged from etc/teams.scm.  LGTM!

Thanks.  ‘teams.scm’ remains useful anyway, in particular since teams in
Forgejo are currently visible only to org members:
<https://codeberg.org/Codeberg-e.V./requests/issues/538>.

Ludo’.




This bug report was last modified 4 days ago.

Previous Next


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