File tree 1 file changed +25
-2
lines changed
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -2418,11 +2418,34 @@ func combineLabelComments(issue *models.Issue) {
2418
2418
c .AddedLabels [0 ] = c .Label
2419
2419
}
2420
2420
} else {
2421
+ // Remove duplicated "added" and "removed" labels
2422
+ // This way, adding and immediately removing a label won't generate a comment.
2423
+ var appendingTo * []* models.Label
2424
+ var other * []* models.Label
2425
+
2421
2426
if removingCur {
2422
- prev .RemovedLabels = append (prev .RemovedLabels , c .Label )
2427
+ appendingTo = & prev .RemovedLabels
2428
+ other = & prev .AddedLabels
2423
2429
} else {
2424
- prev .AddedLabels = append (prev .AddedLabels , c .Label )
2430
+ appendingTo = & prev .AddedLabels
2431
+ other = & prev .RemovedLabels
2432
+ }
2433
+
2434
+ appending := true
2435
+
2436
+ for i := 0 ; i < len (* other ); i ++ {
2437
+ l := (* other )[i ]
2438
+ if l .ID == c .Label .ID {
2439
+ * other = append ((* other )[:i ], (* other )[i + 1 :]... )
2440
+ appending = false
2441
+ break
2442
+ }
2443
+ }
2444
+
2445
+ if appending {
2446
+ * appendingTo = append (* appendingTo , c .Label )
2425
2447
}
2448
+
2426
2449
prev .CreatedUnix = c .CreatedUnix
2427
2450
issue .Comments = append (issue .Comments [:i ], issue .Comments [i + 1 :]... )
2428
2451
continue
You can’t perform that action at this time.
0 commit comments