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