Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot: Fix reviewers in non-teleport/cloud repos #223

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions bot/internal/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ func (r *Assignments) Get(e *env.Environment, changes env.Changes, files []githu
return reviewers
}

func (r *Assignments) repoReviewers(repo string) map[string]Reviewer {
switch repo {
case env.TeleportRepo, env.TeleportERepo:
return r.c.CoreReviewers
case env.CloudRepo:
func (r *Assignments) repoReviewers(e *env.Environment) map[string]Reviewer {
switch e.RepoOwnerTeam() {
case env.CloudTeam:
return r.c.CloudReviewers
case env.CoreTeam:
return r.c.CoreReviewers
}
return map[string]Reviewer{}
}
Expand All @@ -252,7 +252,7 @@ func (r *Assignments) getReleaseReviewers() []string {
func (r *Assignments) getDocsReviewers(e *env.Environment, files []github.PullRequestFile) []string {
// See if any code reviewers are designated preferred reviewers for one of
// the changed docs files. If so, add them as docs reviewers.
repoReviewers := r.repoReviewers(e.Repository)
repoReviewers := r.repoReviewers(e)
a, b := getReviewerSets(e.Author, repoReviewers, r.c.CodeReviewersOmit)
prefCodeReviewers := r.getAllPreferredReviewers(repoReviewers, append(a, b...), files)

Expand All @@ -270,7 +270,7 @@ func (r *Assignments) getDocsReviewers(e *env.Environment, files []github.PullRe
}

func (r *Assignments) getCodeReviewers(e *env.Environment, files []github.PullRequestFile) []string {
reviewers := r.repoReviewers(e.Repository)
reviewers := r.repoReviewers(e)

// Obtain full sets of reviewers.
setA, setB := r.getCodeReviewerSets(e)
Expand Down Expand Up @@ -392,7 +392,7 @@ func (r *Assignments) getCodeReviewerSets(e *env.Environment) ([]string, []strin
n := len(reviewers) / 2
return reviewers[:n], reviewers[n:]
}
return getReviewerSets(e.Author, r.repoReviewers(e.Repository), r.c.CodeReviewersOmit)
return getReviewerSets(e.Author, r.repoReviewers(e), r.c.CodeReviewersOmit)
}

// CheckExternal requires two admins have approved.
Expand Down Expand Up @@ -492,7 +492,7 @@ func (r *Assignments) checkInternalDocsReviews(e *env.Environment, reviews []git
// checkInternalCodeReviews checks whether code review requirements are satisfied
// for a PR authored by an internal employee
func (r *Assignments) checkInternalCodeReviews(e *env.Environment, changes env.Changes, reviews []github.Review) error {
setA, setB := getReviewerSets(e.Author, r.repoReviewers(e.Repository), r.c.CodeReviewersOmit)
setA, setB := getReviewerSets(e.Author, r.repoReviewers(e), r.c.CodeReviewersOmit)

// PRs can be approved if you either have multiple code owners that approve
// or code owner and code reviewer. An exception is for PRs that
Expand Down
Loading