mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09:00
refactor: remove Ctx field from git.Repository (#38500)
This commit is contained in:
@@ -362,11 +362,11 @@ func TestChangeRepoFilesForCreate(t *testing.T) {
|
||||
|
||||
// asserts
|
||||
assert.NoError(t, err)
|
||||
gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo)
|
||||
gitRepo, _ := gitrepo.OpenRepository(repo)
|
||||
defer gitRepo.Close()
|
||||
|
||||
commitID, _ := gitRepo.GetBranchCommitID(opts.NewBranch)
|
||||
lastCommit, _ := gitRepo.GetCommitByPath("new/file.txt")
|
||||
commitID, _ := gitRepo.GetBranchCommitID(t.Context(), opts.NewBranch)
|
||||
lastCommit, _ := gitRepo.GetCommitByPath(t.Context(), "new/file.txt")
|
||||
expectedFileResponse := getExpectedFileResponseForRepoFilesCreate(commitID, lastCommit)
|
||||
assert.NotNil(t, expectedFileResponse)
|
||||
if expectedFileResponse != nil {
|
||||
@@ -399,11 +399,11 @@ func TestChangeRepoFilesForUpdate(t *testing.T) {
|
||||
|
||||
// asserts
|
||||
assert.NoError(t, err)
|
||||
gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo)
|
||||
gitRepo, _ := gitrepo.OpenRepository(repo)
|
||||
defer gitRepo.Close()
|
||||
|
||||
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(gitRepo, opts.Files[0].TreePath)
|
||||
commit, _ := gitRepo.GetBranchCommit(t.Context(), opts.NewBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(t.Context(), gitRepo, opts.Files[0].TreePath)
|
||||
expectedFileResponse := getExpectedFileResponseForRepoFilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When, lastCommit.Author.When)
|
||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||
@@ -435,11 +435,11 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
||||
|
||||
// asserts
|
||||
assert.NoError(t, err)
|
||||
gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo)
|
||||
gitRepo, _ := gitrepo.OpenRepository(repo)
|
||||
defer gitRepo.Close()
|
||||
|
||||
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(gitRepo, opts.Files[0].TreePath)
|
||||
commit, _ := gitRepo.GetBranchCommit(t.Context(), opts.NewBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(t.Context(), gitRepo, opts.Files[0].TreePath)
|
||||
expectedFileResponse := getExpectedFileResponseForRepoFilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When, lastCommit.Author.When)
|
||||
// assert that the old file no longer exists in the last commit of the branch
|
||||
fromEntry, err := commit.GetTreeEntryByPath(ctx, gitRepo, opts.Files[0].FromTreePath)
|
||||
@@ -481,11 +481,11 @@ func TestChangeRepoFilesForUpdateWithFileRename(t *testing.T) {
|
||||
|
||||
// asserts
|
||||
assert.NoError(t, err)
|
||||
gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo)
|
||||
gitRepo, _ := gitrepo.OpenRepository(repo)
|
||||
defer gitRepo.Close()
|
||||
|
||||
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(gitRepo, opts.Files[0].TreePath)
|
||||
commit, _ := gitRepo.GetBranchCommit(t.Context(), repo.DefaultBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(t.Context(), gitRepo, opts.Files[0].TreePath)
|
||||
expectedFileResponse := getExpectedFileResponseForRepoFilesUpdateRename(commit.ID.String(), lastCommit.ID.String())
|
||||
for _, file := range filesResponse.Files {
|
||||
file.LastCommitterDate, file.LastAuthorDate = nil, nil // there might be different time in one operation, so we ignore them
|
||||
@@ -518,11 +518,11 @@ func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
|
||||
|
||||
// asserts
|
||||
assert.NoError(t, err)
|
||||
gitRepo, _ := gitrepo.OpenRepository(t.Context(), repo)
|
||||
gitRepo, _ := gitrepo.OpenRepository(repo)
|
||||
defer gitRepo.Close()
|
||||
|
||||
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(gitRepo, opts.Files[0].TreePath)
|
||||
commit, _ := gitRepo.GetBranchCommit(t.Context(), repo.DefaultBranch)
|
||||
lastCommit, _ := commit.GetCommitByPath(t.Context(), gitRepo, opts.Files[0].TreePath)
|
||||
expectedFileResponse := getExpectedFileResponseForRepoFilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When, lastCommit.Author.When)
|
||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user