diff --git a/etc/teams.scm.in b/etc/teams.scm.in index f42a7f6f28..e50efea786 100644 --- a/etc/teams.scm.in +++ b/etc/teams.scm.in @@ -5,6 +5,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 Ricardo Wurmus ;;; Copyright © 2022 Mathieu Othacehe +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -34,6 +35,7 @@ (ice-9 format) (ice-9 regex) (ice-9 match) + (ice-9 rdelim) (guix ui) (git)) @@ -623,6 +625,15 @@ and REV-END, two git revision strings." (const 0)) files)) +(define (git-patch->commit-id file) + "Parse the commit ID from the first line of FILE, a patch produced with git." + (call-with-input-file file + (lambda (port) + (let ((m (string-match "^From ([0-9a-f]{40})" (read-line port)))) + (unless m + (error "invalid patch file:" file)) + (match:substring m 1))))) + (define (main . args) (match args @@ -631,6 +642,12 @@ and REV-END, two git revision strings." (("cc-members" rev-start rev-end) (apply cc (find-team-by-scope (diff-revisions rev-start rev-end)))) + (("get-maintainer" patch-file) + (let* ((rev-end (git-patch->commit-id patch-file)) + (rev-start (string-append rev-end "^"))) + (apply main "list-members" + (map (compose symbol->string team-id) + (find-team-by-scope (diff-revisions rev-start rev-end)))))) (("list-teams" . args) (list-teams)) (("list-members" . team-names) @@ -646,6 +663,7 @@ Commands: cc get git send-email flags for cc-ing cc-members cc teams related to files changed between revisions list-teams list teams and their members - list-members list members belonging to ~%")))) + list-members list members belonging to + get-maintainer compatibility mode with Linux get_maintainer.pl~%")))) (apply main (cdr (command-line)))