From 0b16001e72177c6cc6203d5c7e3e38083a8b5131 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Thu, 28 Oct 2021 18:56:51 +0200 Subject: [PATCH] Add comment and rename var --- routers/web/repo/issue.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index aa9d838e11cda..0816d413400c5 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2577,6 +2577,8 @@ func combineLabelComments(issue *models.Issue) { if cur.Label != nil { // now cur MUST be label comment if prev.Type == models.CommentTypeLabel { // we can combine them only prev is a label comment if cur.Content != "1" { + // remove labels from the AddedLabels list if the label that was removed is already + // in this list, and if it's not in this list, add the label to RemovedLabels addedAndRemoved := false for i, label := range prev.AddedLabels { if cur.Label.ID == label.ID { @@ -2589,15 +2591,17 @@ func combineLabelComments(issue *models.Issue) { prev.RemovedLabels = append(prev.RemovedLabels, cur.Label) } } else { - addedAndRemoved := false + // remove labels from the RemovedLabels list if the label that was added is already + // in this list, and if it's not in this list, add the label to AddedLabels + removedAndAdded := false for i, label := range prev.RemovedLabels { if cur.Label.ID == label.ID { prev.RemovedLabels = append(prev.RemovedLabels[:i], prev.RemovedLabels[i+1:]...) - addedAndRemoved = true + removedAndAdded = true break } } - if !addedAndRemoved { + if !removedAndAdded { prev.AddedLabels = append(prev.AddedLabels, cur.Label) } }