aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_collaboration.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-12 23:48:20 +0800
committerGitHub <noreply@github.com>2021-12-12 23:48:20 +0800
commit572324049008ac803d3d7c17a7b3a81ef00386fc (patch)
treea9c3709643a23165d27aa67e76f10f26a89936d5 /models/repo_collaboration.go
parent0a7e8327a017c5dd43e552bbcd0d0f056bc1671b (diff)
downloadgitea-572324049008ac803d3d7c17a7b3a81ef00386fc.tar.gz
gitea-572324049008ac803d3d7c17a7b3a81ef00386fc.zip
Some repository refactors (#17950)
* some repository refactors * remove unnecessary code * Fix test * Remove unnecessary banner
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r--models/repo_collaboration.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index ab6a3bafbe..3aca1023e6 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -207,15 +207,13 @@ func DeleteCollaboration(repo *repo_model.Repository, uid int64) (err error) {
}
defer committer.Close()
- sess := db.GetEngine(ctx)
-
- if has, err := sess.Delete(collaboration); err != nil || has == 0 {
+ if has, err := db.GetEngine(ctx).Delete(collaboration); err != nil || has == 0 {
return err
} else if err = recalculateAccesses(ctx, repo); err != nil {
return err
}
- if err = watchRepo(sess, uid, repo.ID, false); err != nil {
+ if err = repo_model.WatchRepoCtx(ctx, uid, repo.ID, false); err != nil {
return err
}
@@ -253,13 +251,12 @@ func reconsiderWatches(ctx context.Context, repo *repo_model.Repository, uid int
if has, err := hasAccess(ctx, uid, repo); err != nil || has {
return err
}
- e := db.GetEngine(ctx)
- if err := watchRepo(e, uid, repo.ID, false); err != nil {
+ if err := repo_model.WatchRepoCtx(ctx, uid, repo.ID, false); err != nil {
return err
}
// Remove all IssueWatches a user has subscribed to in the repository
- return removeIssueWatchersByRepoID(e, uid, repo.ID)
+ return removeIssueWatchersByRepoID(db.GetEngine(ctx), uid, repo.ID)
}
func getRepoTeams(e db.Engine, repo *repo_model.Repository) (teams []*Team, err error) {