Change git.cmd to RunWithContext (#18693)

Change all `cmd...Pipeline` commands to `cmd.RunWithContext`.

#18553

Co-authored-by: Martin Scholz <martin.scholz@versasec.com>
This commit is contained in:
Martin Scholz 2022-02-11 13:47:22 +01:00 committed by GitHub
parent 393ea86ae1
commit 26718a785a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 530 additions and 155 deletions

View file

@ -274,7 +274,13 @@ func TestCantMergeUnrelated(t *testing.T) {
stdin := bytes.NewBufferString("Unrelated File")
var stdout strings.Builder
err = git.NewCommand(git.DefaultContext, "hash-object", "-w", "--stdin").RunInDirFullPipeline(path, &stdout, nil, stdin)
err = git.NewCommand(git.DefaultContext, "hash-object", "-w", "--stdin").RunWithContext(&git.RunContext{
Timeout: -1,
Dir: path,
Stdin: stdin,
Stdout: &stdout,
})
assert.NoError(t, err)
sha := strings.TrimSpace(stdout.String())
@ -301,7 +307,14 @@ func TestCantMergeUnrelated(t *testing.T) {
_, _ = messageBytes.WriteString("\n")
stdout.Reset()
err = git.NewCommand(git.DefaultContext, "commit-tree", treeSha).RunInDirTimeoutEnvFullPipeline(env, -1, path, &stdout, nil, messageBytes)
err = git.NewCommand(git.DefaultContext, "commit-tree", treeSha).
RunWithContext(&git.RunContext{
Env: env,
Timeout: -1,
Dir: path,
Stdin: messageBytes,
Stdout: &stdout,
})
assert.NoError(t, err)
commitSha := strings.TrimSpace(stdout.String())