diff options
author | Ludovic Courtès <ludo@gnu.org> | 2025-06-09 19:03:17 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-06-12 14:38:16 +0200 |
commit | 82748f595f611c772cf19d7c151e4ae47c026dfb (patch) | |
tree | 0ef7559327f6e9e43dc803a61019b4b4079da53d | |
parent | 0d0eae160066e3e02de1d98e8053e2c11f8264be (diff) |
teams: ‘sync-codeberg-teams’ associates teams with ‘guix/guix’.
Fixes guix/guix#466.
Previously those teams would exist at the organization-level but would
not be associated with the ‘guix/guix’ repository, thereby preventing
people from adding them as reviewers and from mentioning them.
* etc/teams.scm (repository-teams, add-repository-team): New Forgejo
requests.
(synchronize-teams): Call the latter.
Change-Id: Ibc6726cda66552ee9dd1df24d57b80f903712e67
-rwxr-xr-x | etc/teams.scm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/etc/teams.scm b/etc/teams.scm index f276877d10..35aad26ef3 100755 --- a/etc/teams.scm +++ b/etc/teams.scm @@ -326,6 +326,19 @@ PARAMETERS." "members" user) => 204) +(define-forgejo-request (repository-teams owner repository) + "Return the list of teams assigned to REPOSITORY of OWNER." + (GET "repos" owner repository "teams" + & '(("limit" . "100"))) ;get up to 100 teams + => 200 + (lambda (port) + (map json->forgejo-team (vector->list (json->scm port))))) + +(define-forgejo-request (add-repository-team owner repository team-name) + "Add TEAM-NAME as a team of OWNER's REPOSITORY." + (PUT "repos" owner repository "teams" team-name) + => 204) + (define (team->forgejo-team team) "Return a Forgejo team derived from TEAM, a <team> record." (forgejo-team (team-id->forgejo-id (team-id team)) @@ -409,7 +422,24 @@ already exists. Lookup team IDs among CURRENT-TEAMS." (lambda (team) (synchronize-team token team #:current-teams teams))) - teams))) + teams) + + ;; Ensure all the teams are associated with the main repository. + (let ((repository-teams (repository-teams token + %codeberg-organization + "guix"))) + (for-each (lambda (missing) + (format (current-error-port) + "adding team '~a' to '~a/guix'~%" + (team-id missing) %codeberg-organization) + (add-repository-team token %codeberg-organization "guix" + (team-id->forgejo-id + (team-id missing)))) + (let ((names (map forgejo-team-name repository-teams))) + (remove (lambda (team) + (member (team-id->forgejo-id (team-id team)) + names)) + teams)))))) |