aboutsummaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-03-29 21:13:41 +0200
committerGitHub <noreply@github.com>2022-03-30 03:13:41 +0800
commit3e88af898a7b8e2697f7e4c3867c34b802d0b660 (patch)
treee8304867b9fd8d78ef0a3da7221d84fb29592c21 /integrations
parent889a8c268ca6a54ff5be19e61b29b10feb4a12e8 (diff)
downloadgitea-3e88af898a7b8e2697f7e4c3867c34b802d0b660.tar.gz
gitea-3e88af898a7b8e2697f7e4c3867c34b802d0b660.zip
Make git.OpenRepository accept Context (#19260)
* OpenRepositoryCtx -> OpenRepository * OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_releases_test.go4
-rw-r--r--integrations/api_repo_file_create_test.go5
-rw-r--r--integrations/api_repo_file_update_test.go3
-rw-r--r--integrations/api_repo_get_contents_list_test.go2
-rw-r--r--integrations/api_repo_get_contents_test.go2
-rw-r--r--integrations/api_repo_git_tags_test.go2
-rw-r--r--integrations/git_test.go2
-rw-r--r--integrations/mirror_pull_test.go2
-rw-r--r--integrations/mirror_push_test.go4
-rw-r--r--integrations/pull_merge_test.go4
-rw-r--r--integrations/pull_update_test.go2
-rw-r--r--integrations/repofiles_update_test.go8
12 files changed, 21 insertions, 19 deletions
diff --git a/integrations/api_releases_test.go b/integrations/api_releases_test.go
index 815b749110..80f53717b6 100644
--- a/integrations/api_releases_test.go
+++ b/integrations/api_releases_test.go
@@ -105,7 +105,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) {
session := loginUser(t, owner.LowerName)
token := getTokenForLoggedInUser(t, session)
- gitRepo, err := git.OpenRepository(repo.RepoPath())
+ gitRepo, err := git.OpenRepository(git.DefaultContext, repo.RepoPath())
assert.NoError(t, err)
defer gitRepo.Close()
@@ -167,7 +167,7 @@ func TestAPICreateReleaseToDefaultBranchOnExistingTag(t *testing.T) {
session := loginUser(t, owner.LowerName)
token := getTokenForLoggedInUser(t, session)
- gitRepo, err := git.OpenRepository(repo.RepoPath())
+ gitRepo, err := git.OpenRepository(git.DefaultContext, repo.RepoPath())
assert.NoError(t, err)
defer gitRepo.Close()
diff --git a/integrations/api_repo_file_create_test.go b/integrations/api_repo_file_create_test.go
index 8bee5d39f4..eb550f1d28 100644
--- a/integrations/api_repo_file_create_test.go
+++ b/integrations/api_repo_file_create_test.go
@@ -5,6 +5,7 @@
package integrations
import (
+ stdCtx "context"
"encoding/base64"
"fmt"
"net/http"
@@ -167,7 +168,7 @@ func TestAPICreateFile(t *testing.T) {
url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
req := NewRequestWithJSON(t, "POST", url, &createFileOptions)
resp := session.MakeRequest(t, req, http.StatusCreated)
- gitRepo, _ := git.OpenRepository(repo1.RepoPath())
+ gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath())
commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName)
expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath)
var fileResponse api.FileResponse
@@ -286,7 +287,7 @@ func TestAPICreateFile(t *testing.T) {
req = NewRequestWithJSON(t, "POST", url, &createFileOptions)
resp = session.MakeRequest(t, req, http.StatusCreated)
emptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user2", Name: "empty-repo"}).(*repo_model.Repository) // public repo
- gitRepo, _ := git.OpenRepository(emptyRepo.RepoPath())
+ gitRepo, _ := git.OpenRepository(stdCtx.Background(), emptyRepo.RepoPath())
commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName)
expectedFileResponse := getExpectedFileResponseForCreate("user2/empty-repo", commitID, treePath)
DecodeJSON(t, resp, &fileResponse)
diff --git a/integrations/api_repo_file_update_test.go b/integrations/api_repo_file_update_test.go
index 63bee11458..0c9c0763f4 100644
--- a/integrations/api_repo_file_update_test.go
+++ b/integrations/api_repo_file_update_test.go
@@ -5,6 +5,7 @@
package integrations
import (
+ stdCtx "context"
"encoding/base64"
"fmt"
"net/http"
@@ -134,7 +135,7 @@ func TestAPIUpdateFile(t *testing.T) {
url := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
req := NewRequestWithJSON(t, "PUT", url, &updateFileOptions)
resp := session.MakeRequest(t, req, http.StatusOK)
- gitRepo, _ := git.OpenRepository(repo1.RepoPath())
+ gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath())
commitID, _ := gitRepo.GetBranchCommitID(updateFileOptions.NewBranchName)
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath)
var fileResponse api.FileResponse
diff --git a/integrations/api_repo_get_contents_list_test.go b/integrations/api_repo_get_contents_list_test.go
index b8822d13ec..42227a9c4b 100644
--- a/integrations/api_repo_get_contents_list_test.go
+++ b/integrations/api_repo_get_contents_list_test.go
@@ -75,7 +75,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
err := repo_service.CreateNewBranch(git.DefaultContext, user2, repo1, repo1.DefaultBranch, newBranch)
assert.NoError(t, err)
// Get the commit ID of the default branch
- gitRepo, err := git.OpenRepository(repo1.RepoPath())
+ gitRepo, err := git.OpenRepository(git.DefaultContext, repo1.RepoPath())
assert.NoError(t, err)
defer gitRepo.Close()
diff --git a/integrations/api_repo_get_contents_test.go b/integrations/api_repo_get_contents_test.go
index bc8471c70d..67f2cb8362 100644
--- a/integrations/api_repo_get_contents_test.go
+++ b/integrations/api_repo_get_contents_test.go
@@ -76,7 +76,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
err := repo_service.CreateNewBranch(git.DefaultContext, user2, repo1, repo1.DefaultBranch, newBranch)
assert.NoError(t, err)
// Get the commit ID of the default branch
- gitRepo, err := git.OpenRepository(repo1.RepoPath())
+ gitRepo, err := git.OpenRepository(git.DefaultContext, repo1.RepoPath())
assert.NoError(t, err)
defer gitRepo.Close()
diff --git a/integrations/api_repo_git_tags_test.go b/integrations/api_repo_git_tags_test.go
index 6aa2f9f642..7884560df8 100644
--- a/integrations/api_repo_git_tags_test.go
+++ b/integrations/api_repo_git_tags_test.go
@@ -31,7 +31,7 @@ func TestAPIGitTags(t *testing.T) {
git.NewCommand(git.DefaultContext, "config", "user.name", user.Name).RunInDir(repo.RepoPath())
git.NewCommand(git.DefaultContext, "config", "user.email", user.Email).RunInDir(repo.RepoPath())
- gitRepo, _ := git.OpenRepository(repo.RepoPath())
+ gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath())
defer gitRepo.Close()
commit, _ := gitRepo.GetBranchCommit("master")
diff --git a/integrations/git_test.go b/integrations/git_test.go
index 675b1879fa..e48d17c9b0 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -624,7 +624,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
return
}
- gitRepo, err := git.OpenRepository(dstPath)
+ gitRepo, err := git.OpenRepository(git.DefaultContext, dstPath)
if !assert.NoError(t, err) {
return
}
diff --git a/integrations/mirror_pull_test.go b/integrations/mirror_pull_test.go
index eb798fe2ce..385f0f5a6f 100644
--- a/integrations/mirror_pull_test.go
+++ b/integrations/mirror_pull_test.go
@@ -52,7 +52,7 @@ func TestMirrorPull(t *testing.T) {
mirror, err := repository.MigrateRepositoryGitData(ctx, user, mirrorRepo, opts, nil)
assert.NoError(t, err)
- gitRepo, err := git.OpenRepository(repoPath)
+ gitRepo, err := git.OpenRepository(git.DefaultContext, repoPath)
assert.NoError(t, err)
defer gitRepo.Close()
diff --git a/integrations/mirror_push_test.go b/integrations/mirror_push_test.go
index c5f45643ec..a73b69e786 100644
--- a/integrations/mirror_push_test.go
+++ b/integrations/mirror_push_test.go
@@ -54,14 +54,14 @@ func testMirrorPush(t *testing.T, u *url.URL) {
ok := mirror_service.SyncPushMirror(context.Background(), mirrors[0].ID)
assert.True(t, ok)
- srcGitRepo, err := git.OpenRepository(srcRepo.RepoPath())
+ srcGitRepo, err := git.OpenRepository(git.DefaultContext, srcRepo.RepoPath())
assert.NoError(t, err)
defer srcGitRepo.Close()
srcCommit, err := srcGitRepo.GetBranchCommit("master")
assert.NoError(t, err)
- mirrorGitRepo, err := git.OpenRepository(mirrorRepo.RepoPath())
+ mirrorGitRepo, err := git.OpenRepository(git.DefaultContext, mirrorRepo.RepoPath())
assert.NoError(t, err)
defer mirrorGitRepo.Close()
diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go
index 2e33d7095f..f865a3371e 100644
--- a/integrations/pull_merge_test.go
+++ b/integrations/pull_merge_test.go
@@ -238,7 +238,7 @@ func TestCantMergeConflict(t *testing.T) {
BaseBranch: "base",
}).(*models.PullRequest)
- gitRepo, err := git.OpenRepository(repo_model.RepoPath(user1.Name, repo1.Name))
+ gitRepo, err := git.OpenRepository(git.DefaultContext, repo_model.RepoPath(user1.Name, repo1.Name))
assert.NoError(t, err)
err = pull.Merge(git.DefaultContext, pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "CONFLICT")
@@ -333,7 +333,7 @@ func TestCantMergeUnrelated(t *testing.T) {
session.MakeRequest(t, req, http.StatusCreated)
// Now this PR could be marked conflict - or at least a race may occur - so drop down to pure code at this point...
- gitRepo, err := git.OpenRepository(path)
+ gitRepo, err := git.OpenRepository(git.DefaultContext, path)
assert.NoError(t, err)
pr := unittest.AssertExistsAndLoadBean(t, &models.PullRequest{
HeadRepoID: repo1.ID,
diff --git a/integrations/pull_update_test.go b/integrations/pull_update_test.go
index dc2803aca0..20b4eaeb4a 100644
--- a/integrations/pull_update_test.go
+++ b/integrations/pull_update_test.go
@@ -90,7 +90,7 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *models.Pul
assert.NoError(t, err)
assert.NotEmpty(t, baseRepo)
- headRepo, err := repo_service.ForkRepository(actor, forkOrg, repo_service.ForkRepoOptions{
+ headRepo, err := repo_service.ForkRepository(git.DefaultContext, actor, forkOrg, repo_service.ForkRepoOptions{
BaseRepo: baseRepo,
Name: "repo-pr-update",
Description: "desc",
diff --git a/integrations/repofiles_update_test.go b/integrations/repofiles_update_test.go
index bb11a048e4..2add99cc86 100644
--- a/integrations/repofiles_update_test.go
+++ b/integrations/repofiles_update_test.go
@@ -202,7 +202,7 @@ func TestCreateOrUpdateRepoFileForCreate(t *testing.T) {
// asserts
assert.NoError(t, err)
- gitRepo, _ := git.OpenRepository(repo.RepoPath())
+ gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath())
defer gitRepo.Close()
commitID, _ := gitRepo.GetBranchCommitID(opts.NewBranch)
@@ -238,7 +238,7 @@ func TestCreateOrUpdateRepoFileForUpdate(t *testing.T) {
// asserts
assert.NoError(t, err)
- gitRepo, _ := git.OpenRepository(repo.RepoPath())
+ gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath())
defer gitRepo.Close()
commitID, _ := gitRepo.GetBranchCommitID(opts.NewBranch)
@@ -273,7 +273,7 @@ func TestCreateOrUpdateRepoFileForUpdateWithFileMove(t *testing.T) {
// asserts
assert.NoError(t, err)
- gitRepo, _ := git.OpenRepository(repo.RepoPath())
+ gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath())
defer gitRepo.Close()
commit, _ := gitRepo.GetBranchCommit(opts.NewBranch)
@@ -323,7 +323,7 @@ func TestCreateOrUpdateRepoFileWithoutBranchNames(t *testing.T) {
// asserts
assert.NoError(t, err)
- gitRepo, _ := git.OpenRepository(repo.RepoPath())
+ gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath())
defer gitRepo.Close()
commitID, _ := gitRepo.GetBranchCommitID(repo.DefaultBranch)