summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2025-05-10 17:12:50 +0200
committerLudovic Courtès <ludo@gnu.org>2025-05-23 11:38:33 +0200
commit8dff81313876a54519ce17e9fda64d4310e2dd5c (patch)
tree6226468bd859748351191d1d178ecf0fcf5991cd
parent3b6e499d5e635e2189f1bf60279dbf5175c404bd (diff)
teams: Add “codeowners” action.
* etc/teams.scm (team->codeowners-snippet, export-codeowners): New procedures. (main): Add “codeowners” action. * doc/contributing.texi (Teams): Document it. Change-Id: I601443981af374d85160833f7096d8c973873fb1
-rw-r--r--doc/contributing.texi7
-rwxr-xr-xetc/teams.scm31
2 files changed, 38 insertions, 0 deletions
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 1f6e7b1571c..dd32cb7327e 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -2733,6 +2733,13 @@ $ guix shell -D guix
[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 b3d55b26b91..f7617e724ee 100755
--- a/etc/teams.scm
+++ b/etc/teams.scm
@@ -14,6 +14,7 @@ exec $pre_inst_env_maybe guix repl -- "$0" "$@"
;;; Copyright © 2022 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2025 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2025 Cayetano Santos <csantosb@inventati.org>
+;;; Copyright © 2025 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1023,6 +1024,34 @@ and REV-END, two git revision strings."
(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
@@ -1056,6 +1085,8 @@ and REV-END, two git revision strings."
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>]