@@ -113,6 +113,7 @@ func (a *Approval) ComputeApprovalStatus(ctx context.Context, pr *PR) (*Result,
113113 }
114114 }
115115
116+ allAllowedMembers := map [string ]bool {}
116117 // Check if each required team has approved the pull request.
117118 for _ , rule := range rules {
118119 matched , err := a .isRuleMatched (ctx , rule , pr )
@@ -149,11 +150,12 @@ func (a *Approval) ComputeApprovalStatus(ctx context.Context, pr *PR) (*Result,
149150 return nil , err
150151 }
151152
153+ addMembers (allAllowedMembers , members )
154+
152155 allowed , ignored , err := a .allowedAndIgnoreReviewers (ctx , pr , members , rule .IgnoreContributorApproval )
153156 if err != nil {
154157 return nil , err
155158 }
156-
157159 // Check whether the current team has approved the PR.
158160 approvalCount := countApprovalsForTeam (reviews , allowed )
159161 // Need to use full team handle here, as we'll be comparing recorded handles
@@ -164,19 +166,31 @@ func (a *Approval) ComputeApprovalStatus(ctx context.Context, pr *PR) (*Result,
164166 state .addMatchedRule (mr )
165167 }
166168
169+ state .updateInvalidReviewers (allAllowedMembers )
170+
167171 result := state .result (a .log , teams ) // state should not be consumed past this point
168172
169173 if result .pendingReviewsWaiting () {
170- err := a .client .ReportIgnoredReviews (
171- ctx , pr .OwnerLogin , pr .RepoName , pr .Number , result .IgnoredReviewers ())
172- if err != nil {
174+ if err := a .client .ReportIgnoredReviews (
175+ ctx , pr .OwnerLogin , pr .RepoName , pr .Number , result .IgnoredReviewers ()); err != nil {
176+ return nil , err
177+ }
178+
179+ if err := a .client .ReportInvalidReviews (
180+ ctx , pr .OwnerLogin , pr .RepoName , pr .Number , result .InvalidReviewers ()); err != nil {
173181 return nil , err
174182 }
175183 }
176184
177185 return result , nil
178186}
179187
188+ func addMembers (allowed map [string ]bool , members []* github.User ) {
189+ for _ , m := range members {
190+ allowed [m .GetLogin ()] = true
191+ }
192+ }
193+
180194func (a * Approval ) isRuleMatched (ctx context.Context , rule configuration.Rule , pr * PR ) (bool , error ) {
181195 // Check whether the pull request's body matches the aforementioned regex (ignoring case).
182196 prBodyMatch , err := a .isRegexMatched (ctx , pr .OwnerLogin , pr .RepoName , pr .Number , rule .Regex , pr .Body )
0 commit comments