From 7e35ab283e9470ddee702a2e2b37cbc88b9ee049 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 11 Feb 2017 16:10:50 +0800 Subject: [PATCH 1/2] bug fixed for deleted label in issue comment --- models/issue_comment.go | 11 ++++++----- models/issue_label.go | 5 +++++ templates/repo/issue/view_content.tmpl | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/models/issue_comment.go b/models/issue_comment.go index 2eadba810b304..e133cc049bdcb 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 970b3fcc4cfc1..015e7f128dcca 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() } diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 40993e54d2186..06f6265d07426 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -145,6 +145,7 @@ {{else if eq .Type 7}} + {{if .Label}}
@@ -153,6 +154,7 @@ {{.Poster.Name}} {{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}}
+ {{end}} {{else if eq .Type 8}}
From 8e938df881938f72f6a58d714141aa7336b07c68 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 11 Feb 2017 18:32:51 +0800 Subject: [PATCH 2/2] fix indent --- templates/repo/issue/view_content.tmpl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 06f6265d07426..381c80cdaf9c8 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -146,14 +146,14 @@
{{else if eq .Type 7}} {{if .Label}} -
- - - - - {{.Poster.Name}} - {{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}} -
+
+ + + + + {{.Poster.Name}} + {{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}} +
{{end}} {{else if eq .Type 8}}