From fc0c5e6506a47884f2850ff82d5e3692ef412701 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Thu, 1 Oct 2020 21:46:07 +0100 Subject: [PATCH] (Re)Load issue labels when changing them (Re)Load issue labels when labels are added or removed This means that the label state that the webhooks produce accurately matches the changes that they are reporting. Fix #10660 Signed-off-by: Andrew Thornton --- models/issue.go | 5 +++++ models/issue_label.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/models/issue.go b/models/issue.go index 82bd21455b2fe..ee75623f53025 100644 --- a/models/issue.go +++ b/models/issue.go @@ -549,6 +549,11 @@ func (issue *Issue) ReplaceLabels(labels []*Label, doer *User) (err error) { } } + issue.Labels = nil + if err = issue.loadLabels(sess); err != nil { + return err + } + return sess.Commit() } diff --git a/models/issue_label.go b/models/issue_label.go index 2b519ee71deb4..6b029198fcecf 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -670,6 +670,11 @@ func NewIssueLabel(issue *Issue, label *Label, doer *User) (err error) { return err } + issue.Labels = nil + if err = issue.loadLabels(sess); err != nil { + return err + } + return sess.Commit() } @@ -699,6 +704,11 @@ func NewIssueLabels(issue *Issue, labels []*Label, doer *User) (err error) { return err } + issue.Labels = nil + if err = issue.loadLabels(sess); err != nil { + return err + } + return sess.Commit() } @@ -742,5 +752,10 @@ func DeleteIssueLabel(issue *Issue, label *Label, doer *User) (err error) { return err } + issue.Labels = nil + if err = issue.loadLabels(sess); err != nil { + return err + } + return sess.Commit() }