fix no protection rule violations blocking PR merge (#680)

pull/3417/head
Marko Gacesa 2023-10-16 13:53:40 +00:00 committed by Harness
parent 419fe92dde
commit 63d1565a51
1 changed files with 11 additions and 3 deletions

View File

@ -55,16 +55,24 @@ func (s ruleSet) CanMerge(ctx context.Context, in CanMergeInput) ([]types.RuleVi
return nil, err
}
backFillRule(vs, &r)
violations = append(violations, backFillRule(vs, &r)...)
violations = append(violations, vs...)
}
return violations, nil
}
func backFillRule(vs []types.RuleViolations, rule *types.Rule) {
func backFillRule(vs []types.RuleViolations, rule *types.Rule) []types.RuleViolations {
violations := make([]types.RuleViolations, 0, len(vs))
for i := range vs {
if len(vs[i].Violations) == 0 {
continue
}
vs[i].Rule = rule
violations = append(violations, vs[i])
}
return violations
}