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