summaryrefslogtreecommitdiffstats
path: root/integrations/pull_update_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-01-19 23:26:57 +0000
committerGitHub <noreply@github.com>2022-01-19 23:26:57 +0000
commit5cb0c9aa0d7eed087055b1efca79628957207d36 (patch)
treed117a514e1f17e5f6bfcda1be273f6a971112663 /integrations/pull_update_test.go
parent4563148a61ba892e8f2bb66342f00a950bcd5315 (diff)
downloadgitea-5cb0c9aa0d7eed087055b1efca79628957207d36.tar.gz
gitea-5cb0c9aa0d7eed087055b1efca79628957207d36.zip
Propagate context and ensure git commands run in request context (#17868)
This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'integrations/pull_update_test.go')
-rw-r--r--integrations/pull_update_test.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/integrations/pull_update_test.go b/integrations/pull_update_test.go
index ede0cc9896..b80b85fbeb 100644
--- a/integrations/pull_update_test.go
+++ b/integrations/pull_update_test.go
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/git"
pull_service "code.gitea.io/gitea/services/pull"
repo_service "code.gitea.io/gitea/services/repository"
files_service "code.gitea.io/gitea/services/repository/files"
@@ -28,7 +29,7 @@ func TestAPIPullUpdate(t *testing.T) {
pr := createOutdatedPR(t, user, org26)
//Test GetDiverging
- diffCount, err := pull_service.GetDiverging(pr)
+ diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
assert.NoError(t, err)
assert.EqualValues(t, 1, diffCount.Behind)
assert.EqualValues(t, 1, diffCount.Ahead)
@@ -41,7 +42,7 @@ func TestAPIPullUpdate(t *testing.T) {
session.MakeRequest(t, req, http.StatusOK)
//Test GetDiverging after update
- diffCount, err = pull_service.GetDiverging(pr)
+ diffCount, err = pull_service.GetDiverging(git.DefaultContext, pr)
assert.NoError(t, err)
assert.EqualValues(t, 0, diffCount.Behind)
assert.EqualValues(t, 2, diffCount.Ahead)
@@ -56,7 +57,7 @@ func TestAPIPullUpdateByRebase(t *testing.T) {
pr := createOutdatedPR(t, user, org26)
//Test GetDiverging
- diffCount, err := pull_service.GetDiverging(pr)
+ diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
assert.NoError(t, err)
assert.EqualValues(t, 1, diffCount.Behind)
assert.EqualValues(t, 1, diffCount.Ahead)
@@ -69,7 +70,7 @@ func TestAPIPullUpdateByRebase(t *testing.T) {
session.MakeRequest(t, req, http.StatusOK)
//Test GetDiverging after update
- diffCount, err = pull_service.GetDiverging(pr)
+ diffCount, err = pull_service.GetDiverging(git.DefaultContext, pr)
assert.NoError(t, err)
assert.EqualValues(t, 0, diffCount.Behind)
assert.EqualValues(t, 1, diffCount.Ahead)
@@ -98,7 +99,7 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *models.Pul
assert.NotEmpty(t, headRepo)
//create a commit on base Repo
- _, err = files_service.CreateOrUpdateRepoFile(baseRepo, actor, &files_service.UpdateRepoFileOptions{
+ _, err = files_service.CreateOrUpdateRepoFile(git.DefaultContext, baseRepo, actor, &files_service.UpdateRepoFileOptions{
TreePath: "File_A",
Message: "Add File A",
Content: "File A",
@@ -121,7 +122,7 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *models.Pul
assert.NoError(t, err)
//create a commit on head Repo
- _, err = files_service.CreateOrUpdateRepoFile(headRepo, actor, &files_service.UpdateRepoFileOptions{
+ _, err = files_service.CreateOrUpdateRepoFile(git.DefaultContext, headRepo, actor, &files_service.UpdateRepoFileOptions{
TreePath: "File_B",
Message: "Add File on PR branch",
Content: "File B",
@@ -160,7 +161,7 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *models.Pul
BaseRepo: baseRepo,
Type: models.PullRequestGitea,
}
- err = pull_service.NewPullRequest(baseRepo, pullIssue, nil, nil, pullRequest, nil)
+ err = pull_service.NewPullRequest(git.DefaultContext, baseRepo, pullIssue, nil, nil, pullRequest, nil)
assert.NoError(t, err)
issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{Title: "Test Pull -to-update-"}).(*models.Issue)