From 124b072f0b69650baff086b9688d198f5a6761af Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 1 Apr 2022 10:55:30 +0800 Subject: Remove `git.Command.Run` and `git.Command.RunInDir*` (#19280) Follows #19266, #8553, Close #18553, now there are only three `Run..(&RunOpts{})` functions. * before: `stdout, err := RunInDir(path)` * now: `stdout, _, err := RunStdString(&git.RunOpts{Dir:path})` --- integrations/pull_merge_test.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'integrations/pull_merge_test.go') diff --git a/integrations/pull_merge_test.go b/integrations/pull_merge_test.go index f865a3371e..4e063bbdb6 100644 --- a/integrations/pull_merge_test.go +++ b/integrations/pull_merge_test.go @@ -269,25 +269,24 @@ func TestCantMergeUnrelated(t *testing.T) { }).(*repo_model.Repository) path := repo_model.RepoPath(user1.Name, repo1.Name) - _, err := git.NewCommand(git.DefaultContext, "read-tree", "--empty").RunInDir(path) + err := git.NewCommand(git.DefaultContext, "read-tree", "--empty").Run(&git.RunOpts{Dir: path}) assert.NoError(t, err) stdin := bytes.NewBufferString("Unrelated File") var stdout strings.Builder - err = git.NewCommand(git.DefaultContext, "hash-object", "-w", "--stdin").RunWithContext(&git.RunContext{ - Timeout: -1, - Dir: path, - Stdin: stdin, - Stdout: &stdout, + err = git.NewCommand(git.DefaultContext, "hash-object", "-w", "--stdin").Run(&git.RunOpts{ + Dir: path, + Stdin: stdin, + Stdout: &stdout, }) assert.NoError(t, err) sha := strings.TrimSpace(stdout.String()) - _, err = git.NewCommand(git.DefaultContext, "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").RunStdString(&git.RunOpts{Dir: path}) assert.NoError(t, err) - treeSha, err := git.NewCommand(git.DefaultContext, "write-tree").RunInDir(path) + treeSha, _, err := git.NewCommand(git.DefaultContext, "write-tree").RunStdString(&git.RunOpts{Dir: path}) assert.NoError(t, err) treeSha = strings.TrimSpace(treeSha) @@ -308,17 +307,16 @@ func TestCantMergeUnrelated(t *testing.T) { stdout.Reset() err = git.NewCommand(git.DefaultContext, "commit-tree", treeSha). - RunWithContext(&git.RunContext{ - Env: env, - Timeout: -1, - Dir: path, - Stdin: messageBytes, - Stdout: &stdout, + Run(&git.RunOpts{ + Env: env, + Dir: path, + Stdin: messageBytes, + Stdout: &stdout, }) assert.NoError(t, err) commitSha := strings.TrimSpace(stdout.String()) - _, err = git.NewCommand(git.DefaultContext, "branch", "unrelated", commitSha).RunInDir(path) + _, _, err = git.NewCommand(git.DefaultContext, "branch", "unrelated", commitSha).RunStdString(&git.RunOpts{Dir: path}) assert.NoError(t, err) testEditFileToNewBranch(t, session, "user1", "repo1", "master", "conflict", "README.md", "Hello, World (Edited Once)\n") -- cgit v1.2.3