From 6a57364dc833ceb85e582e79c40c211c67130781 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Thu, 5 Mar 2020 09:58:02 +0200 Subject: [PATCH] Delete dependencies when deleting a repository (#10608) Co-authored-by: zeripath Co-authored-by: Lauris BH --- models/repo.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/models/repo.go b/models/repo.go index ac9efaf7a1a3..672507819add 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1520,6 +1520,18 @@ func DeleteRepository(doer *User, uid, repoID int64) error { return err } + // Dependencies for issues in this repository + if _, err = sess.In("issue_id", deleteCond). + Delete(&IssueDependency{}); err != nil { + return err + } + + // Delete dependencies for issues in other repositories + if _, err = sess.In("dependency_id", deleteCond). + Delete(&IssueDependency{}); err != nil { + return err + } + if _, err = sess.In("issue_id", deleteCond). Delete(&IssueUser{}); err != nil { return err