2022-06-06 16:01:49 +08:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-28 02:20:29 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-06-06 16:01:49 +08:00
|
|
|
|
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
2023-03-01 06:17:51 +08:00
|
|
|
"context"
|
|
|
|
|
2022-06-06 16:01:49 +08: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-03-01 06:17:51 +08:00
|
|
|
func GetReviewerTeams(ctx context.Context, repo *repo_model.Repository) ([]*organization.Team, error) {
|
|
|
|
if err := repo.LoadOwner(ctx); err != nil {
|
2022-06-06 16:01:49 +08:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if !repo.Owner.IsOrganization() {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2023-03-01 06:17:51 +08:00
|
|
|
return organization.GetTeamsWithAccessToRepo(ctx, repo.OwnerID, repo.ID, perm.AccessModeRead)
|
2022-06-06 16:01:49 +08:00
|
|
|
}
|