From patchwork Wed Sep 7 15:21:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 42273 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 040B427BBEA; Wed, 7 Sep 2022 16:25:59 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4EE2027BBE9 for ; Wed, 7 Sep 2022 16:25:58 +0100 (BST) Received: from localhost ([::1]:43248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVww9-0004js-HO for patchwork@mira.cbaines.net; Wed, 07 Sep 2022 11:25:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVwvG-000409-Np for guix-patches@gnu.org; Wed, 07 Sep 2022 11:25:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVwvG-0007oX-Aj for guix-patches@gnu.org; Wed, 07 Sep 2022 11:25:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oVwvG-0002xH-6I for guix-patches@gnu.org; Wed, 07 Sep 2022 11:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57646] [PATCH 1/3] etc: teams: Add scope support. References: <20220907151622.4912-1-othacehe@gnu.org> In-Reply-To: <20220907151622.4912-1-othacehe@gnu.org> Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 07 Sep 2022 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57646 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57646@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 57646-submit@debbugs.gnu.org id=B57646.166256428211316 (code B ref 57646); Wed, 07 Sep 2022 15:25:02 +0000 Received: (at 57646) by debbugs.gnu.org; 7 Sep 2022 15:24:42 +0000 Received: from localhost ([127.0.0.1]:55842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oVwuv-0002wR-UD for submit@debbugs.gnu.org; Wed, 07 Sep 2022 11:24:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oVwut-0002w2-Nb for 57646@debbugs.gnu.org; Wed, 07 Sep 2022 11:24:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVwuo-0007kg-HJ for 57646@debbugs.gnu.org; Wed, 07 Sep 2022 11:24:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=Cy3EiO4dOhd9wlG/Z9o68dWi6QXN+WgS534gKCh91/I=; b=aAN+triOtRSKrK 9MwnSlSifvW42avLc0hZUVPX/riqqEFweJZzkjSv859FCN2zxCViVeqjytU2gccJ8UyY18lhi03UZ XRFvy7zU5sBJ8WR5OpzmnspN7s61uTRMj5mq/ag1KrJfNKw6la9JbFdY8eXEGRLEOErN8WY7NCt42 tkWuq+rbpp9D14Q3uO+vapgvcC4SE9GJe1NuzR+kMjwvnJNjWaA+q2fxNrKVzN84QJ3sAbb243pi+ NzmbI66hcuRtpRkIXPL4NmaxIPWebSk93d2lkE3DRWshNmzZozOpItcSyK5kg/Two5RPeFR/kh4gt oKGk9wHH2cfrwftFb+Gg==; Received: from ppp079167215024.access.hol.gr ([79.167.215.24]:59606 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVwuo-0005B6-0b; Wed, 07 Sep 2022 11:24:34 -0400 From: Mathieu Othacehe Date: Wed, 7 Sep 2022 17:21:48 +0200 Message-Id: <20220907152150.5687-1-othacehe@gnu.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Add a scope list to each team. This list defines all the files and directories that are mentored by the team. Also add a cc-members command that takes two Git revision strings as input, add returns the members that should be CC'ed given the files impacted between the two revisions. * etc/teams.scm.in ()[scope]: New field. (team, list-teams): Adapt those procedures. (find-team-by-scope, diff-revisions): New procedures. (main): Add a "cc-members" command. --- etc/teams.scm.in | 74 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/etc/teams.scm.in b/etc/teams.scm.in index 38b7ab8e1d..37937a02ff 100644 --- a/etc/teams.scm.in +++ b/etc/teams.scm.in @@ -4,6 +4,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 Ricardo Wurmus +;;; Copyright © 2022 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,23 +23,27 @@ ;;; Commentary: -;; This code defines development teams and team members. +;; This code defines development teams and team members, as well as their +;; scope. ;;; Code: (use-modules (srfi srfi-1) (srfi srfi-9) + (srfi srfi-26) (ice-9 format) (ice-9 match) - (guix ui)) + (guix ui) + (git)) (define-record-type - (make-team id name description members) + (make-team id name description members scope) team? (id team-id) (name team-name) (description team-description) - (members team-members set-team-members!)) + (members team-members set-team-members!) + (scope team-scope)) (define-record-type (make-person name email) @@ -49,11 +54,13 @@ (define-record-type (define* (person name #:optional email) (make-person name email)) -(define* (team id #:key name description (members '())) +(define* (team id #:key name description (members '()) + (scope '())) (make-team id (or name (symbol->string id)) description - members)) + members + scope)) (define %teams (make-hash-table)) @@ -268,6 +275,22 @@ (define (find-team name) (error (format #false "no such team: ~a~%" name)))) +(define (find-team-by-scope files) + "Return the team(s) which scope matches at least one of the FILES, as list +of file names as string." + (hash-fold + (lambda (key team acc) + (if (any (lambda (file) + (any (lambda (scope) + ;; XXX: Add regex support? + (string-prefix? scope file)) + (team-scope team))) + files) + (cons team acc) + acc)) + '() + %teams)) + (define (cc . teams) "Return arguments for `git send-email' to notify the members of the given TEAMS when a patch is received by Debbugs." @@ -289,7 +312,7 @@ (define port* (or port (current-output-port))) (team-members team))) (define (list-teams) - "Print all teams and their members." + "Print all teams, their scope and their members." (define port* (current-output-port)) (define width* (%text-width)) (hash-for-each @@ -299,7 +322,7 @@ (define width* (%text-width)) id: ~a name: ~a description: ~a -members: +~amembers: " (team-id team) (team-name team) @@ -308,15 +331,48 @@ (define width* (%text-width)) (string->recutils (fill-paragraph text width* (string-length "description: "))))) - "")) + "") + (if (not (null? (team-scope team))) + (format #f "scope: ~{~s ~}~%" (team-scope team)) + "")) (list-members team port* "+ ") (newline)) %teams)) + +(define (diff-revisions rev-start rev-end) + "Return the list of added, modified or removed files between REV-START +and REV-END, two git revision strings." + (let* ((repository (repository-open (getcwd))) + (commit1 (commit-lookup repository + (object-id + (revparse-single repository rev-start)))) + (commit2 (commit-lookup repository + (object-id + (revparse-single repository rev-end)))) + (diff (diff-tree-to-tree repository + (commit-tree commit1) + (commit-tree commit2))) + (files '())) + (diff-foreach + diff + (lambda (delta progress) + (set! files + (cons (diff-file-path (diff-delta-old-file delta)) files)) + 0) + (const 0) + (const 0) + (const 0)) + files)) + + (define (main . args) (match args (("cc" . team-names) (apply cc (map find-team team-names))) + (("cc-members" rev-start rev-end) + (apply cc (find-team-by-scope + (diff-revisions rev-start rev-end)))) (("list-teams" . args) (list-teams)) (("list-members" . team-names)