Bug fixed for deleted label in issue comment (#904)

* bug fixed for deleted label in issue comment

* fix indent
This commit is contained in:
Lunny Xiao 2017-02-11 20:56:57 +08:00 committed by GitHub
parent 442145dbd3
commit 8a0be5e9f0
3 changed files with 21 additions and 13 deletions

View file

@ -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)
}
return nil
}

View file

@ -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()
}

View file

@ -145,6 +145,7 @@
</div>
</div>
{{else if eq .Type 7}}
{{if .Label}}
<div class="event">
<span class="octicon octicon-primitive-dot"></span>
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
@ -153,6 +154,7 @@
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
{{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}}</span>
</div>
{{end}}
{{else if eq .Type 8}}
<div class="event">
<span class="octicon octicon-primitive-dot"></span>