diff options
author | Jason Song <i@wolfogre.com> | 2023-01-09 11:50:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 11:50:54 +0800 |
commit | 7adc2de46404e32ed33f999d308ed56232cdfea5 (patch) | |
tree | 2404a22b5fa8a941eb5bfd16fd717fab29d899e4 /services/pull | |
parent | b878155b8741c2769b6aa50a80609c36822451c9 (diff) | |
download | gitea-7adc2de46404e32ed33f999d308ed56232cdfea5.tar.gz gitea-7adc2de46404e32ed33f999d308ed56232cdfea5.zip |
Use context parameter in models/git (#22367)
After #22362, we can feel free to use transactions without
`db.DefaultContext`.
And there are still lots of models using `db.DefaultContext`, I think we
should refactor them carefully and one by one.
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services/pull')
-rw-r--r-- | services/pull/lfs.go | 5 | ||||
-rw-r--r-- | services/pull/update.go | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/services/pull/lfs.go b/services/pull/lfs.go index 4b9826bedd..dc4ca006e4 100644 --- a/services/pull/lfs.go +++ b/services/pull/lfs.go @@ -11,6 +11,7 @@ import ( "strconv" "sync" + "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/modules/git/pipeline" @@ -115,7 +116,7 @@ func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg } // Then we need to check that this pointer is in the db - if _, err := git_model.GetLFSMetaObjectByOid(pr.HeadRepo.ID, pointer.Oid); err != nil { + if _, err := git_model.GetLFSMetaObjectByOid(db.DefaultContext, pr.HeadRepo.ID, pointer.Oid); err != nil { if err == git_model.ErrLFSObjectNotExist { log.Warn("During merge of: %d in %-v, there is a pointer to LFS Oid: %s which although present in the LFS store is not associated with the head repo %-v", pr.Index, pr.BaseRepo, pointer.Oid, pr.HeadRepo) continue @@ -128,7 +129,7 @@ func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg // Therefore it should be associated with the base repo meta := &git_model.LFSMetaObject{Pointer: pointer} meta.RepositoryID = pr.BaseRepoID - if _, err := git_model.NewLFSMetaObject(meta); err != nil { + if _, err := git_model.NewLFSMetaObject(db.DefaultContext, meta); err != nil { _ = catFileBatchReader.CloseWithError(err) break } diff --git a/services/pull/update.go b/services/pull/update.go index e09dbf6244..6f976140c5 100644 --- a/services/pull/update.go +++ b/services/pull/update.go @@ -115,7 +115,7 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest, } // Update function need push permission - if pr.ProtectedBranch != nil && !pr.ProtectedBranch.CanUserPush(user.ID) { + if pr.ProtectedBranch != nil && !pr.ProtectedBranch.CanUserPush(ctx, user.ID) { return false, false, nil } |