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

This commit is contained in:
Marko Gacesa 2023-10-16 13:53:40 +00:00 committed by Harness
parent 419fe92dde
commit 63d1565a51

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
}