summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-02-11 20:56:57 +0800
committerGitHub <noreply@github.com>2017-02-11 20:56:57 +0800
commit8a0be5e9f01caaf3667c420f08541ac7c26127b8 (patch)
treea1f2cfc2e7fd4932cd350121746266c03506e86a /models
parent442145dbd348a18915de80faea68f30a9d9309b3 (diff)
downloadgitea-8a0be5e9f01caaf3667c420f08541ac7c26127b8.tar.gz
gitea-8a0be5e9f01caaf3667c420f08541ac7c26127b8.zip
Bug fixed for deleted label in issue comment (#904)
* bug fixed for deleted label in issue comment * fix indent
Diffstat (limited to 'models')
-rw-r--r--models/issue_comment.go11
-rw-r--r--models/issue_label.go5
2 files changed, 11 insertions, 5 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 2eadba810b..e133cc049b 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -214,12 +214,13 @@ func (c *Comment) LoadLabel() error {
has, err := x.ID(c.LabelID).Get(&label)
if err != nil {
return err
- } else if !has {
- return ErrLabelNotExist{
- LabelID: c.LabelID,
- }
+ } else if has {
+ c.Label = &label
+ } else {
+ // Ignore Label is deleted, but not clear this table
+ log.Warn("Commit %d cannot load label %d", c.ID, c.LabelID)
}
- c.Label = &label
+
return nil
}
diff --git a/models/issue_label.go b/models/issue_label.go
index 970b3fcc4c..015e7f128d 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -249,6 +249,11 @@ func DeleteLabel(repoID, labelID int64) error {
return err
}
+ // Clear label id in comment table
+ if _, err = sess.Where("label_id = ?", labelID).Cols("label_id").Update(&Comment{}); err != nil {
+ return err
+ }
+
return sess.Commit()
}