diff options
Diffstat (limited to 'services/repository')
-rw-r--r-- | services/repository/branch.go | 6 | ||||
-rw-r--r-- | services/repository/files/commit.go | 2 | ||||
-rw-r--r-- | services/repository/files/patch.go | 2 | ||||
-rw-r--r-- | services/repository/files/update.go | 9 | ||||
-rw-r--r-- | services/repository/files/upload.go | 7 | ||||
-rw-r--r-- | services/repository/lfs.go | 2 | ||||
-rw-r--r-- | services/repository/push.go | 2 |
7 files changed, 16 insertions, 14 deletions
diff --git a/services/repository/branch.go b/services/repository/branch.go index e5ffbbeb74..8717fee23b 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -119,7 +119,7 @@ func RenameBranch(repo *repo_model.Repository, doer *user_model.User, gitRepo *g return "from_not_exist", nil } - if err := git_model.RenameBranch(repo, from, to, func(isDefault bool) error { + if err := git_model.RenameBranch(db.DefaultContext, repo, from, to, func(isDefault bool) error { err2 := gitRepo.RenameBranch(from, to) if err2 != nil { return err2 @@ -159,7 +159,7 @@ func DeleteBranch(doer *user_model.User, repo *repo_model.Repository, gitRepo *g return ErrBranchIsDefault } - isProtected, err := git_model.IsProtectedBranch(repo.ID, branchName) + isProtected, err := git_model.IsProtectedBranch(db.DefaultContext, repo.ID, branchName) if err != nil { return err } @@ -197,7 +197,7 @@ func DeleteBranch(doer *user_model.User, repo *repo_model.Repository, gitRepo *g log.Error("Update: %v", err) } - if err := git_model.AddDeletedBranch(repo.ID, branchName, commit.ID.String(), doer.ID); err != nil { + if err := git_model.AddDeletedBranch(db.DefaultContext, repo.ID, branchName, commit.ID.String(), doer.ID); err != nil { log.Warn("AddDeletedBranch: %v", err) } diff --git a/services/repository/files/commit.go b/services/repository/files/commit.go index 74f9eb868d..9d237f1e22 100644 --- a/services/repository/files/commit.go +++ b/services/repository/files/commit.go @@ -38,7 +38,7 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato } gitRepo.Close() - if err := git_model.NewCommitStatus(git_model.NewCommitStatusOptions{ + if err := git_model.NewCommitStatus(ctx, git_model.NewCommitStatusOptions{ Repo: repo, Creator: creator, SHA: sha, diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go index b5eef8c091..33f4b6c9dc 100644 --- a/services/repository/files/patch.go +++ b/services/repository/files/patch.go @@ -70,7 +70,7 @@ func (opts *ApplyDiffPatchOptions) Validate(ctx context.Context, repo *repo_mode if err != nil { return err } - if protectedBranch != nil && !protectedBranch.CanUserPush(doer.ID) { + if protectedBranch != nil && !protectedBranch.CanUserPush(ctx, doer.ID) { return models.ErrUserCannotCommit{ UserName: doer.LowerName, } diff --git a/services/repository/files/update.go b/services/repository/files/update.go index f7a41ef24c..30cfd9e2dd 100644 --- a/services/repository/files/update.go +++ b/services/repository/files/update.go @@ -12,6 +12,7 @@ import ( "time" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" @@ -75,7 +76,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *repo_model.Repository) (st if setting.LFS.StartServer { pointer, _ := lfs.ReadPointerFromBuffer(buf) if pointer.IsValid() { - meta, err := git_model.GetLFSMetaObjectByOid(repo.ID, pointer.Oid) + meta, err := git_model.GetLFSMetaObjectByOid(db.DefaultContext, repo.ID, pointer.Oid) if err != nil && err != git_model.ErrLFSObjectNotExist { // return default return "UTF-8", false @@ -423,7 +424,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do if lfsMetaObject != nil { // We have an LFS object - create it - lfsMetaObject, err = git_model.NewLFSMetaObject(lfsMetaObject) + lfsMetaObject, err = git_model.NewLFSMetaObject(ctx, lfsMetaObject) if err != nil { return nil, err } @@ -434,7 +435,7 @@ func CreateOrUpdateRepoFile(ctx context.Context, repo *repo_model.Repository, do } if !exist { if err := contentStore.Put(lfsMetaObject.Pointer, strings.NewReader(opts.Content)); err != nil { - if _, err2 := git_model.RemoveLFSMetaObjectByOid(repo.ID, lfsMetaObject.Oid); err2 != nil { + if _, err2 := git_model.RemoveLFSMetaObjectByOid(ctx, repo.ID, lfsMetaObject.Oid); err2 != nil { return nil, fmt.Errorf("Error whilst removing failed inserted LFS object %s: %v (Prev Error: %w)", lfsMetaObject.Oid, err2, err) } return nil, err @@ -472,7 +473,7 @@ func VerifyBranchProtection(ctx context.Context, repo *repo_model.Repository, do if len(glob) != 0 { isUnprotectedFile = protectedBranch.IsUnprotectedFile(glob, treePath) } - if !protectedBranch.CanUserPush(doer.ID) && !isUnprotectedFile { + if !protectedBranch.CanUserPush(ctx, doer.ID) && !isUnprotectedFile { return models.ErrUserCannotCommit{ UserName: doer.LowerName, } diff --git a/services/repository/files/upload.go b/services/repository/files/upload.go index 240564d401..e7289dd60d 100644 --- a/services/repository/files/upload.go +++ b/services/repository/files/upload.go @@ -10,6 +10,7 @@ import ( "path" "strings" + "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" @@ -40,7 +41,7 @@ func cleanUpAfterFailure(infos *[]uploadInfo, t *TemporaryUploadRepository, orig continue } if !info.lfsMetaObject.Existing { - if _, err := git_model.RemoveLFSMetaObjectByOid(t.repo.ID, info.lfsMetaObject.Oid); err != nil { + if _, err := git_model.RemoveLFSMetaObjectByOid(db.DefaultContext, t.repo.ID, info.lfsMetaObject.Oid); err != nil { original = fmt.Errorf("%w, %v", original, err) // We wrap the original error - as this is the underlying error that required the fallback } } @@ -64,7 +65,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use for i, upload := range uploads { // Check file is not lfs locked, will return nil if lock setting not enabled filepath := path.Join(opts.TreePath, upload.Name) - lfsLock, err := git_model.GetTreePathLock(repo.ID, filepath) + lfsLock, err := git_model.GetTreePathLock(ctx, repo.ID, filepath) if err != nil { return err } @@ -132,7 +133,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use if infos[i].lfsMetaObject == nil { continue } - infos[i].lfsMetaObject, err = git_model.NewLFSMetaObject(infos[i].lfsMetaObject) + infos[i].lfsMetaObject, err = git_model.NewLFSMetaObject(ctx, infos[i].lfsMetaObject) if err != nil { // OK Now we need to cleanup return cleanUpAfterFailure(&infos, t, err) diff --git a/services/repository/lfs.go b/services/repository/lfs.go index 0e88d359a8..7806e20a9f 100644 --- a/services/repository/lfs.go +++ b/services/repository/lfs.go @@ -74,7 +74,7 @@ func GarbageCollectLFSMetaObjectsForRepo(ctx context.Context, repo *repo_model.R return nil } // Non-existent pointer file - _, err = git_model.RemoveLFSMetaObjectByOidFn(repo.ID, metaObject.Oid, func(count int64) error { + _, err = git_model.RemoveLFSMetaObjectByOidFn(ctx, repo.ID, metaObject.Oid, func(count int64) error { if count > 0 { return nil } diff --git a/services/repository/push.go b/services/repository/push.go index f1eedb8e08..dc8d564cb4 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -251,7 +251,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { notification.NotifyPushCommits(db.DefaultContext, pusher, repo, opts, commits) - if err = git_model.RemoveDeletedBranchByName(repo.ID, branch); err != nil { + if err = git_model.RemoveDeletedBranchByName(ctx, repo.ID, branch); err != nil { log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, branch, err) } |