~ruther/guix-local

82748f595f611c772cf19d7c151e4ae47c026dfb — Ludovic Courtès 1 year, 1 month ago 0d0eae1
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
1 files changed, 31 insertions(+), 1 deletions(-)

M etc/teams.scm
M etc/teams.scm => etc/teams.scm +31 -1
@@ 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))))))