diff options
Diffstat (limited to 'services/repository')
-rw-r--r-- | services/repository/adopt.go | 2 | ||||
-rw-r--r-- | services/repository/archiver/archiver.go | 2 | ||||
-rw-r--r-- | services/repository/files/upload.go | 2 | ||||
-rw-r--r-- | services/repository/fork.go | 2 | ||||
-rw-r--r-- | services/repository/push.go | 6 | ||||
-rw-r--r-- | services/repository/repository.go | 10 | ||||
-rw-r--r-- | services/repository/repository_test.go | 2 | ||||
-rw-r--r-- | services/repository/transfer.go | 2 |
8 files changed, 14 insertions, 14 deletions
diff --git a/services/repository/adopt.go b/services/repository/adopt.go index fb7adcfd29..828068e8ec 100644 --- a/services/repository/adopt.go +++ b/services/repository/adopt.go @@ -116,7 +116,7 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r // Re-fetch the repository from database before updating it (else it would // override changes that were done earlier with sql) - if repo, err = repo_model.GetRepositoryByIDCtx(ctx, repo.ID); err != nil { + if repo, err = repo_model.GetRepositoryByID(ctx, repo.ID); err != nil { return fmt.Errorf("getRepositoryByID: %w", err) } diff --git a/services/repository/archiver/archiver.go b/services/repository/archiver/archiver.go index 94fff6ffa2..1da4425cfc 100644 --- a/services/repository/archiver/archiver.go +++ b/services/repository/archiver/archiver.go @@ -226,7 +226,7 @@ func doArchive(r *ArchiveRequest) (*repo_model.RepoArchiver, error) { rd.Close() }() done := make(chan error, 1) // Ensure that there is some capacity which will ensure that the goroutine below can always finish - repo, err := repo_model.GetRepositoryByID(archiver.RepoID) + repo, err := repo_model.GetRepositoryByID(ctx, archiver.RepoID) if err != nil { return nil, fmt.Errorf("archiver.LoadRepo failed: %w", err) } diff --git a/services/repository/files/upload.go b/services/repository/files/upload.go index 0ada3885b1..240564d401 100644 --- a/services/repository/files/upload.go +++ b/services/repository/files/upload.go @@ -69,7 +69,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use return err } if lfsLock != nil && lfsLock.OwnerID != doer.ID { - u, err := user_model.GetUserByID(lfsLock.OwnerID) + u, err := user_model.GetUserByID(ctx, lfsLock.OwnerID) if err != nil { return err } diff --git a/services/repository/fork.go b/services/repository/fork.go index cf9b3992cd..3ed0f4ffa5 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -184,7 +184,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork // ConvertForkToNormalRepository convert the provided repo from a forked repo to normal repo func ConvertForkToNormalRepository(repo *repo_model.Repository) error { err := db.WithTx(db.DefaultContext, func(ctx context.Context) error { - repo, err := repo_model.GetRepositoryByIDCtx(ctx, repo.ID) + repo, err := repo_model.GetRepositoryByID(ctx, repo.ID) if err != nil { return err } diff --git a/services/repository/push.go b/services/repository/push.go index bce01cb76a..f1eedb8e08 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -81,7 +81,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("PushUpdates: %s/%s", optsList[0].RepoUserName, optsList[0].RepoName)) defer finished() - repo, err := repo_model.GetRepositoryByOwnerAndName(optsList[0].RepoUserName, optsList[0].RepoName) + repo, err := repo_model.GetRepositoryByOwnerAndName(ctx, optsList[0].RepoUserName, optsList[0].RepoName) if err != nil { return fmt.Errorf("GetRepositoryByOwnerAndName failed: %w", err) } @@ -109,7 +109,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { if opts.IsTag() { // If is tag reference if pusher == nil || pusher.ID != opts.PusherID { var err error - if pusher, err = user_model.GetUserByID(opts.PusherID); err != nil { + if pusher, err = user_model.GetUserByID(ctx, opts.PusherID); err != nil { return err } } @@ -149,7 +149,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { } else if opts.IsBranch() { // If is branch reference if pusher == nil || pusher.ID != opts.PusherID { var err error - if pusher, err = user_model.GetUserByID(opts.PusherID); err != nil { + if pusher, err = user_model.GetUserByID(ctx, opts.PusherID); err != nil { return err } } diff --git a/services/repository/repository.go b/services/repository/repository.go index 859c32cf8f..41fae4b4cf 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -103,24 +103,24 @@ func UpdateRepository(repo *repo_model.Repository, visibilityChanged bool) (err } // LinkedRepository returns the linked repo if any -func LinkedRepository(a *repo_model.Attachment) (*repo_model.Repository, unit.Type, error) { +func LinkedRepository(ctx context.Context, a *repo_model.Attachment) (*repo_model.Repository, unit.Type, error) { if a.IssueID != 0 { - iss, err := issues_model.GetIssueByID(db.DefaultContext, a.IssueID) + iss, err := issues_model.GetIssueByID(ctx, a.IssueID) if err != nil { return nil, unit.TypeIssues, err } - repo, err := repo_model.GetRepositoryByID(iss.RepoID) + repo, err := repo_model.GetRepositoryByID(ctx, iss.RepoID) unitType := unit.TypeIssues if iss.IsPull { unitType = unit.TypePullRequests } return repo, unitType, err } else if a.ReleaseID != 0 { - rel, err := repo_model.GetReleaseByID(db.DefaultContext, a.ReleaseID) + rel, err := repo_model.GetReleaseByID(ctx, a.ReleaseID) if err != nil { return nil, unit.TypeReleases, err } - repo, err := repo_model.GetRepositoryByID(rel.RepoID) + repo, err := repo_model.GetRepositoryByID(ctx, rel.RepoID) return repo, unit.TypeReleases, err } return nil, -1, nil diff --git a/services/repository/repository_test.go b/services/repository/repository_test.go index 5f5283bddb..892a11a23e 100644 --- a/services/repository/repository_test.go +++ b/services/repository/repository_test.go @@ -31,7 +31,7 @@ func TestLinkedRepository(t *testing.T) { t.Run(tc.name, func(t *testing.T) { attach, err := repo_model.GetAttachmentByID(db.DefaultContext, tc.attachID) assert.NoError(t, err) - repo, unitType, err := LinkedRepository(attach) + repo, unitType, err := LinkedRepository(db.DefaultContext, attach) assert.NoError(t, err) if tc.expectedRepo != nil { assert.Equal(t, tc.expectedRepo.ID, repo.ID) diff --git a/services/repository/transfer.go b/services/repository/transfer.go index af28f5a4a5..9fba9c44eb 100644 --- a/services/repository/transfer.go +++ b/services/repository/transfer.go @@ -43,7 +43,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *repo_model.Reposit } repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) - newRepo, err := repo_model.GetRepositoryByID(repo.ID) + newRepo, err := repo_model.GetRepositoryByID(db.DefaultContext, repo.ID) if err != nil { return err } |