From 63d1565a51c8db1025a331c7e15bcfa9672e2171 Mon Sep 17 00:00:00 2001 From: Marko Gacesa Date: Mon, 16 Oct 2023 13:53:40 +0000 Subject: [PATCH] fix no protection rule violations blocking PR merge (#680) --- app/services/protection/set.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/services/protection/set.go b/app/services/protection/set.go index e9990d58b..ac6d7911e 100644 --- a/app/services/protection/set.go +++ b/app/services/protection/set.go @@ -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 }