1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Delete Labels & IssueLabels on Repo Delete too (#15039) (#15051)

* Doctor: find IssueLabels without existing label

* Repo Delete: delete labels & issue_labels too
This commit is contained in:
6543
2021-03-19 22:13:39 +01:00
committed by GitHub
parent 909f2be99d
commit 70e4134130
4 changed files with 50 additions and 0 deletions

View File

@@ -764,3 +764,15 @@ func DeleteIssueLabel(issue *Issue, label *Label, doer *User) (err error) {
return sess.Commit()
}
func deleteLabelsByRepoID(sess Engine, repoID int64) error {
deleteCond := builder.Select("id").From("label").Where(builder.Eq{"label.repo_id": repoID})
if _, err := sess.In("label_id", deleteCond).
Delete(&IssueLabel{}); err != nil {
return err
}
_, err := sess.Delete(&Label{RepoID: repoID})
return err
}