diff options
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/api_repo_git_tags_test.go | 4 | ||||
-rw-r--r-- | integrations/git_helper_for_declarative_test.go | 12 | ||||
-rw-r--r-- | integrations/git_test.go | 22 | ||||
-rw-r--r-- | integrations/pull_merge_test.go | 12 | ||||
-rw-r--r-- | integrations/repo_tag_test.go | 4 |
5 files changed, 27 insertions, 27 deletions
diff --git a/integrations/api_repo_git_tags_test.go b/integrations/api_repo_git_tags_test.go index e2ee738723..6aa2f9f642 100644 --- a/integrations/api_repo_git_tags_test.go +++ b/integrations/api_repo_git_tags_test.go @@ -28,8 +28,8 @@ func TestAPIGitTags(t *testing.T) { token := getTokenForLoggedInUser(t, session) // Set up git config for the tagger - git.NewCommand("config", "user.name", user.Name).RunInDir(repo.RepoPath()) - git.NewCommand("config", "user.email", user.Email).RunInDir(repo.RepoPath()) + 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()) defer gitRepo.Close() diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go index e1b6b779e9..674fad5f18 100644 --- a/integrations/git_helper_for_declarative_test.go +++ b/integrations/git_helper_for_declarative_test.go @@ -134,7 +134,7 @@ func doGitInitTestRepository(dstPath string) func(*testing.T) { // Init repository in dstPath assert.NoError(t, git.InitRepository(git.DefaultContext, dstPath, false)) // forcibly set default branch to master - _, err := git.NewCommand("symbolic-ref", "HEAD", git.BranchPrefix+"master").RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, "symbolic-ref", "HEAD", git.BranchPrefix+"master").RunInDir(dstPath) assert.NoError(t, err) assert.NoError(t, os.WriteFile(filepath.Join(dstPath, "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", dstPath)), 0o644)) assert.NoError(t, git.AddChanges(dstPath, true)) @@ -153,28 +153,28 @@ func doGitInitTestRepository(dstPath string) func(*testing.T) { func doGitAddRemote(dstPath, remoteName string, u *url.URL) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommand("remote", "add", remoteName, u.String()).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, "remote", "add", remoteName, u.String()).RunInDir(dstPath) assert.NoError(t, err) } } func doGitPushTestRepository(dstPath string, args ...string) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommand(append([]string{"push", "-u"}, args...)...).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, append([]string{"push", "-u"}, args...)...).RunInDir(dstPath) assert.NoError(t, err) } } func doGitPushTestRepositoryFail(dstPath string, args ...string) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommand(append([]string{"push"}, args...)...).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, append([]string{"push"}, args...)...).RunInDir(dstPath) assert.Error(t, err) } } func doGitCreateBranch(dstPath, branch string) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommand("checkout", "-b", branch).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, "checkout", "-b", branch).RunInDir(dstPath) assert.NoError(t, err) } } @@ -188,7 +188,7 @@ func doGitCheckoutBranch(dstPath string, args ...string) func(*testing.T) { func doGitMerge(dstPath string, args ...string) func(*testing.T) { return func(t *testing.T) { - _, err := git.NewCommand(append([]string{"merge"}, args...)...).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, append([]string{"merge"}, args...)...).RunInDir(dstPath) assert.NoError(t, err) } } diff --git a/integrations/git_test.go b/integrations/git_test.go index e5a85eb756..e1df8ac546 100644 --- a/integrations/git_test.go +++ b/integrations/git_test.go @@ -160,9 +160,9 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin return } prefix := "lfs-data-file-" - _, err := git.NewCommand("lfs").AddArguments("install").RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, "lfs").AddArguments("install").RunInDir(dstPath) assert.NoError(t, err) - _, err = git.NewCommand("lfs").AddArguments("track", prefix+"*").RunInDir(dstPath) + _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("track", prefix+"*").RunInDir(dstPath) assert.NoError(t, err) err = git.AddChanges(dstPath, false, ".gitattributes") assert.NoError(t, err) @@ -292,20 +292,20 @@ func lockTest(t *testing.T, repoPath string) { } func lockFileTest(t *testing.T, filename, repoPath string) { - _, err := git.NewCommand("lfs").AddArguments("locks").RunInDir(repoPath) + _, err := git.NewCommand(git.DefaultContext, "lfs").AddArguments("locks").RunInDir(repoPath) assert.NoError(t, err) - _, err = git.NewCommand("lfs").AddArguments("lock", filename).RunInDir(repoPath) + _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("lock", filename).RunInDir(repoPath) assert.NoError(t, err) - _, err = git.NewCommand("lfs").AddArguments("locks").RunInDir(repoPath) + _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("locks").RunInDir(repoPath) assert.NoError(t, err) - _, err = git.NewCommand("lfs").AddArguments("unlock", filename).RunInDir(repoPath) + _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("unlock", filename).RunInDir(repoPath) assert.NoError(t, err) } func doCommitAndPush(t *testing.T, size int, repoPath, prefix string) string { name, err := generateCommitWithNewData(size, repoPath, "user2@example.com", "User Two", prefix) assert.NoError(t, err) - _, err = git.NewCommand("push", "origin", "master").RunInDir(repoPath) // Push + _, err = git.NewCommand(git.DefaultContext, "push", "origin", "master").RunInDir(repoPath) // Push assert.NoError(t, err) return name } @@ -671,7 +671,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB }) t.Run("Push", func(t *testing.T) { - _, err := git.NewCommand("push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunInDir(dstPath) if !assert.NoError(t, err) { return } @@ -692,7 +692,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB assert.Contains(t, "Testing commit 1", prMsg.Body) assert.Equal(t, commit, prMsg.Head.Sha) - _, err = git.NewCommand("push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunInDir(dstPath) + _, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunInDir(dstPath) if !assert.NoError(t, err) { return } @@ -745,7 +745,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB }) t.Run("Push2", func(t *testing.T) { - _, err := git.NewCommand("push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunInDir(dstPath) + _, err := git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunInDir(dstPath) if !assert.NoError(t, err) { return } @@ -757,7 +757,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB assert.Equal(t, false, prMsg.HasMerged) assert.Equal(t, commit, prMsg.Head.Sha) - _, err = git.NewCommand("push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunInDir(dstPath) + _, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunInDir(dstPath) if !assert.NoError(t, err) { return } diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go index 49e7dc04ec..57a9868678 100644 --- a/integrations/pull_merge_test.go +++ b/integrations/pull_merge_test.go @@ -269,19 +269,19 @@ func TestCantMergeUnrelated(t *testing.T) { }).(*repo_model.Repository) path := repo_model.RepoPath(user1.Name, repo1.Name) - _, err := git.NewCommand("read-tree", "--empty").RunInDir(path) + _, err := git.NewCommand(git.DefaultContext, "read-tree", "--empty").RunInDir(path) assert.NoError(t, err) stdin := bytes.NewBufferString("Unrelated File") var stdout strings.Builder - err = git.NewCommand("hash-object", "-w", "--stdin").RunInDirFullPipeline(path, &stdout, nil, stdin) + err = git.NewCommand(git.DefaultContext, "hash-object", "-w", "--stdin").RunInDirFullPipeline(path, &stdout, nil, stdin) assert.NoError(t, err) sha := strings.TrimSpace(stdout.String()) - _, err = git.NewCommand("update-index", "--add", "--replace", "--cacheinfo", "100644", sha, "somewher-over-the-rainbow").RunInDir(path) + _, err = git.NewCommand(git.DefaultContext, "update-index", "--add", "--replace", "--cacheinfo", "100644", sha, "somewher-over-the-rainbow").RunInDir(path) assert.NoError(t, err) - treeSha, err := git.NewCommand("write-tree").RunInDir(path) + treeSha, err := git.NewCommand(git.DefaultContext, "write-tree").RunInDir(path) assert.NoError(t, err) treeSha = strings.TrimSpace(treeSha) @@ -301,11 +301,11 @@ func TestCantMergeUnrelated(t *testing.T) { _, _ = messageBytes.WriteString("\n") stdout.Reset() - err = git.NewCommand("commit-tree", treeSha).RunInDirTimeoutEnvFullPipeline(env, -1, path, &stdout, nil, messageBytes) + err = git.NewCommand(git.DefaultContext, "commit-tree", treeSha).RunInDirTimeoutEnvFullPipeline(env, -1, path, &stdout, nil, messageBytes) assert.NoError(t, err) commitSha := strings.TrimSpace(stdout.String()) - _, err = git.NewCommand("branch", "unrelated", commitSha).RunInDir(path) + _, err = git.NewCommand(git.DefaultContext, "branch", "unrelated", commitSha).RunInDir(path) assert.NoError(t, err) testEditFileToNewBranch(t, session, "user1", "repo1", "master", "conflict", "README.md", "Hello, World (Edited Once)\n") diff --git a/integrations/repo_tag_test.go b/integrations/repo_tag_test.go index fbca1ac7db..20bfc555b8 100644 --- a/integrations/repo_tag_test.go +++ b/integrations/repo_tag_test.go @@ -66,10 +66,10 @@ func TestCreateNewTagProtected(t *testing.T) { doGitClone(dstPath, u)(t) - _, err = git.NewCommand("tag", "v-2").RunInDir(dstPath) + _, err = git.NewCommand(git.DefaultContext, "tag", "v-2").RunInDir(dstPath) assert.NoError(t, err) - _, err = git.NewCommand("push", "--tags").RunInDir(dstPath) + _, err = git.NewCommand(git.DefaultContext, "push", "--tags").RunInDir(dstPath) assert.Error(t, err) assert.Contains(t, err.Error(), "Tag v-2 is protected") }) |