aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorMartin Scholz <martin.scholz83@outlook.com>2022-02-11 13:47:22 +0100
committerGitHub <noreply@github.com>2022-02-11 13:47:22 +0100
commit26718a785ac49f17eab51ad0f5324d036b810f73 (patch)
tree9c8371e01460dacf8e65c88b3526e2123525c717 /routers
parent393ea86ae192325e45d7fac0fc6a277da8fb0fca (diff)
downloadgitea-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 'routers')
-rw-r--r--routers/private/hook_verification.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/routers/private/hook_verification.go b/routers/private/hook_verification.go
index 565cb273e7..683ed8d071 100644
--- a/routers/private/hook_verification.go
+++ b/routers/private/hook_verification.go
@@ -45,9 +45,12 @@ func verifyCommits(oldCommitID, newCommitID string, repo *git.Repository, env []
// This is safe as force pushes are already forbidden
err = git.NewCommand(repo.Ctx, "rev-list", oldCommitID+"..."+newCommitID).
- RunInDirTimeoutEnvFullPipelineFunc(env, -1, repo.Path,
- stdoutWriter, nil, nil,
- func(ctx context.Context, cancel context.CancelFunc) error {
+ RunWithContext(&git.RunContext{
+ Env: env,
+ Timeout: -1,
+ Dir: repo.Path,
+ Stdout: stdoutWriter,
+ PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
_ = stdoutWriter.Close()
err := readAndVerifyCommitsFromShaReader(stdoutReader, repo, env)
if err != nil {
@@ -56,7 +59,8 @@ func verifyCommits(oldCommitID, newCommitID string, repo *git.Repository, env []
}
_ = stdoutReader.Close()
return err
- })
+ },
+ })
if err != nil && !isErrUnverifiedCommit(err) {
log.Error("Unable to check commits from %s to %s in %s: %v", oldCommitID, newCommitID, repo.Path, err)
}
@@ -89,9 +93,12 @@ func readAndVerifyCommit(sha string, repo *git.Repository, env []string) error {
hash := git.MustIDFromString(sha)
return git.NewCommand(repo.Ctx, "cat-file", "commit", sha).
- RunInDirTimeoutEnvFullPipelineFunc(env, -1, repo.Path,
- stdoutWriter, nil, nil,
- func(ctx context.Context, cancel context.CancelFunc) error {
+ RunWithContext(&git.RunContext{
+ Env: env,
+ Timeout: -1,
+ Dir: repo.Path,
+ Stdout: stdoutWriter,
+ PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
_ = stdoutWriter.Close()
commit, err := git.CommitFromReader(repo, hash, stdoutReader)
if err != nil {
@@ -105,7 +112,8 @@ func readAndVerifyCommit(sha string, repo *git.Repository, env []string) error {
}
}
return nil
- })
+ },
+ })
}
type errUnverifiedCommit struct {