2022-06-06 02:01:49 -06:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 11:20:29 -07:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-06-06 02:01:49 -06:00
|
|
|
|
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
2023-02-28 15:17:51 -07:00
|
|
|
"context"
|
|
|
|
|
2022-06-06 02:01:49 -06:00
|
|
|
"code.gitea.io/gitea/models/organization"
|
|
|
|
"code.gitea.io/gitea/models/perm"
|
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetReviewerTeams get all teams can be requested to review
|
2023-02-28 15:17:51 -07:00
|
|
|
func GetReviewerTeams(ctx context.Context, repo *repo_model.Repository) ([]*organization.Team, error) {
|
|
|
|
if err := repo.LoadOwner(ctx); err != nil {
|
2022-06-06 02:01:49 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if !repo.Owner.IsOrganization() {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2023-02-28 15:17:51 -07:00
|
|
|
return organization.GetTeamsWithAccessToRepo(ctx, repo.OwnerID, repo.ID, perm.AccessModeRead)
|
2022-06-06 02:01:49 -06:00
|
|
|
}
|