Skip to content

Commit

Permalink
Fixed error in assignment logic.
Browse files Browse the repository at this point in the history
Fixed error in assignment logic where some admin reviewers were omitted.
  • Loading branch information
russjones committed Dec 3, 2021
1 parent 0e96258 commit 675fb3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/robot/internal/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ func (r *Assignments) getCodeReviewerSets(author string) ([]string, []string) {
v, ok := r.c.CodeReviewers[author]
if !ok || v.Team == "Internal" {
reviewers := r.getAdminReviewers(author)
return reviewers, reviewers
n := len(reviewers) / 2
return reviewers[:n], reviewers[n:]
}

return getReviewerSets(author, v.Team, r.c.CodeReviewers, r.c.CodeReviewersOmit)
Expand All @@ -207,22 +208,26 @@ func (r *Assignments) CheckInternal(author string, reviews map[string]*github.Re

switch {
case docs && code:
log.Printf("Check: Found docs and code changes.")
if err := r.checkDocsReviews(author, reviews); err != nil {
return trace.Wrap(err)
}
if err := r.checkCodeReviews(author, reviews); err != nil {
return trace.Wrap(err)
}
case !docs && code:
log.Printf("Check: Found code changes.")
if err := r.checkCodeReviews(author, reviews); err != nil {
return trace.Wrap(err)
}
case docs && !code:
log.Printf("Check: Found docs changes.")
if err := r.checkDocsReviews(author, reviews); err != nil {
return trace.Wrap(err)
}
// Strange state, an empty commit? Check admins.
case !docs && !code:
log.Printf("Check: Found no docs or code changes.")
if checkN(r.getAdminReviewers(author), reviews) < 2 {
return trace.BadParameter("requires two admin approvals")
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/robot/internal/review/review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func TestGetCodeReviewers(t *testing.T) {
},
},
author: "5",
setA: []string{"1", "2"},
setB: []string{"1", "2"},
setA: []string{"1"},
setB: []string{"2"},
},
{
desc: "normal",
Expand Down

0 comments on commit 675fb3d

Please sign in to comment.