diff options
author | Martin Scholz <martin.scholz83@outlook.com> | 2022-02-11 13:47:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 13:47:22 +0100 |
commit | 26718a785ac49f17eab51ad0f5324d036b810f73 (patch) | |
tree | 9c8371e01460dacf8e65c88b3526e2123525c717 /modules/git/repo_attribute.go | |
parent | 393ea86ae192325e45d7fac0fc6a277da8fb0fca (diff) | |
download | gitea-26718a785ac49f17eab51ad0f5324d036b810f73.tar.gz gitea-26718a785ac49f17eab51ad0f5324d036b810f73.zip |
Change git.cmd to RunWithContext (#18693)
Change all `cmd...Pipeline` commands to `cmd.RunWithContext`.
#18553
Co-authored-by: Martin Scholz <martin.scholz@versasec.com>
Diffstat (limited to 'modules/git/repo_attribute.go')
-rw-r--r-- | modules/git/repo_attribute.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index c63dfacdfc..d31203aabd 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -76,7 +76,13 @@ func (repo *Repository) CheckAttribute(opts CheckAttributeOpts) (map[string]map[ cmd := NewCommand(repo.Ctx, cmdArgs...) - if err := cmd.RunInDirTimeoutEnvPipeline(env, -1, repo.Path, stdOut, stdErr); err != nil { + if err := cmd.RunWithContext(&RunContext{ + Env: env, + Timeout: -1, + Dir: repo.Path, + Stdout: stdOut, + Stderr: stdErr, + }); err != nil { return nil, fmt.Errorf("failed to run check-attr: %v\n%s\n%s", err, stdOut.String(), stdErr.String()) } @@ -182,9 +188,17 @@ func (c *CheckAttributeReader) Run() error { _ = c.Close() }() stdErr := new(bytes.Buffer) - err := c.cmd.RunInDirTimeoutEnvFullPipelineFunc(c.env, -1, c.Repo.Path, c.stdOut, stdErr, c.stdinReader, func(_ context.Context, _ context.CancelFunc) error { - close(c.running) - return nil + err := c.cmd.RunWithContext(&RunContext{ + Env: c.env, + Timeout: -1, + Dir: c.Repo.Path, + Stdin: c.stdinReader, + Stdout: c.stdOut, + Stderr: stdErr, + PipelineFunc: func(_ context.Context, _ context.CancelFunc) error { + close(c.running) + return nil + }, }) if err != nil && c.ctx.Err() != nil && err.Error() != "signal: killed" { return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String()) |