summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-03-05 13:56:53 +0000
committerGitHub <noreply@github.com>2020-03-05 13:56:53 +0000
commitc19ac41b34fa327aee3e10cb01bfbe539b32705d (patch)
treea101a9f9b4490660ca350f1648232d8ebd686dd5
parentfd85d31cb4a01cb7fdf77f78342bc417bc802cdf (diff)
downloadgitea-c19ac41b34fa327aee3e10cb01bfbe539b32705d.tar.gz
gitea-c19ac41b34fa327aee3e10cb01bfbe539b32705d.zip
Delete dependencies when deleting a repository (#10608) (#10616)
Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r--models/repo.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 804320a2b7..ed44a5e680 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1856,6 +1856,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