aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go
index 4382bd7dc5..0594c6c6f3 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -676,15 +676,33 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) {
sess.Rollback()
return err
}
- if _, err = sess.Delete(&Issue{RepoId: repoId}); err != nil {
+ if _, err = sess.Delete(&IssueUser{RepoId: repoId}); err != nil {
sess.Rollback()
return err
}
- if _, err = sess.Delete(&IssueUser{RepoId: repoId}); err != nil {
+ if _, err = sess.Delete(&Milestone{RepoId: repoId}); err != nil {
sess.Rollback()
return err
}
- if _, err = sess.Delete(&Milestone{RepoId: repoId}); err != nil {
+ if _, err = sess.Delete(&Release{RepoId: repoId}); err != nil {
+ sess.Rollback()
+ return err
+ }
+
+ // Delete comments.
+ if err = orm.Iterate(&Issue{RepoId: repoId}, func(idx int, bean interface{}) error {
+ issue := bean.(*Issue)
+ if _, err = sess.Delete(&Comment{IssueId: issue.Id}); err != nil {
+ sess.Rollback()
+ return err
+ }
+ return nil
+ }); err != nil {
+ sess.Rollback()
+ return err
+ }
+
+ if _, err = sess.Delete(&Issue{RepoId: repoId}); err != nil {
sess.Rollback()
return err
}