diff --git a/models/repo.go b/models/repo.go index 811c54c5e..c11639d30 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1743,12 +1743,12 @@ func DeleteRepositoryLabel(id int64, owner *User) (err error) { return err } - // TODO remove Repository <> RepositoryLabel relationship - label := &RepositoryLabel{ID: id, OwnerID: owner.ID} - if _, err = sess.Delete(label); err != nil { + if _, err = sess.Delete(&RepositoryRepoLabel{LabelID: id}); err != nil { + return fmt.Errorf("remove repository label '%d': %v", id, err) + } + if _, err = sess.Delete(&RepositoryLabel{ID: id, OwnerID: owner.ID}); err != nil { return fmt.Errorf("remove repository label '%d': %v", id, err) } - sess.Where("label_id = ?", id).Delete(&RepositoryRepoLabel{}) return sess.Commit() }