diff --git a/doc/contributing.texi b/doc/contributing.texi index 1f6e7b1571..dd32cb7327 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 b3d55b26b9..f7617e724e 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 ;;; Copyright © 2025 Jelle Licht ;;; Copyright © 2025 Cayetano Santos +;;; Copyright © 2025 Ludovic Courtès ;;; ;;; 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 []