diff options
author | 6543 <6543@obermui.de> | 2022-02-06 20:01:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-06 20:01:47 +0100 |
commit | 3043eb36bfcd7ddf29202b958b91942826a8182b (patch) | |
tree | f6bfcb38648f07ff8132558ff826b8b1aac003ec /routers | |
parent | 8ae5e6d7fdd577ebf0807bf33a4cdeef35d254d9 (diff) | |
download | gitea-3043eb36bfcd7ddf29202b958b91942826a8182b.tar.gz gitea-3043eb36bfcd7ddf29202b958b91942826a8182b.zip |
Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/private/hook_pre_receive.go | 2 | ||||
-rw-r--r-- | routers/private/hook_verification.go | 4 | ||||
-rw-r--r-- | routers/web/repo/http.go | 10 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go index 649bfa5cf3..85464deb29 100644 --- a/routers/private/hook_pre_receive.go +++ b/routers/private/hook_pre_receive.go @@ -183,7 +183,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID, refFullN // 2. Disallow force pushes to protected branches if git.EmptySHA != oldCommitID { - output, err := git.NewCommandContext(ctx, "rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDirWithEnv(repo.RepoPath(), ctx.env) + output, err := git.NewCommand(ctx, "rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDirWithEnv(repo.RepoPath(), ctx.env) if err != nil { log.Error("Unable to detect force push between: %s and %s in %-v Error: %v", oldCommitID, newCommitID, repo, err) ctx.JSON(http.StatusInternalServerError, private.Response{ diff --git a/routers/private/hook_verification.go b/routers/private/hook_verification.go index 5940045dc6..565cb273e7 100644 --- a/routers/private/hook_verification.go +++ b/routers/private/hook_verification.go @@ -44,7 +44,7 @@ func verifyCommits(oldCommitID, newCommitID string, repo *git.Repository, env [] }() // This is safe as force pushes are already forbidden - err = git.NewCommandContext(repo.Ctx, "rev-list", oldCommitID+"..."+newCommitID). + 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 { @@ -88,7 +88,7 @@ func readAndVerifyCommit(sha string, repo *git.Repository, env []string) error { }() hash := git.MustIDFromString(sha) - return git.NewCommandContext(repo.Ctx, "cat-file", "commit", 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 { diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go index 32811734d3..a27a60cb84 100644 --- a/routers/web/repo/http.go +++ b/routers/web/repo/http.go @@ -328,7 +328,7 @@ func dummyInfoRefs(ctx *context.Context) { return } - refs, err := git.NewCommandContext(ctx, "receive-pack", "--stateless-rpc", "--advertise-refs", ".").RunInDirBytes(tmpDir) + refs, err := git.NewCommand(ctx, "receive-pack", "--stateless-rpc", "--advertise-refs", ".").RunInDirBytes(tmpDir) if err != nil { log.Error(fmt.Sprintf("%v - %s", err, string(refs))) } @@ -412,7 +412,7 @@ func (h *serviceHandler) sendFile(contentType, file string) { var safeGitProtocolHeader = regexp.MustCompile(`^[0-9a-zA-Z]+=[0-9a-zA-Z]+(:[0-9a-zA-Z]+=[0-9a-zA-Z]+)*$`) func getGitConfig(ctx gocontext.Context, option, dir string) string { - out, err := git.NewCommandContext(ctx, "config", option).RunInDir(dir) + out, err := git.NewCommand(ctx, "config", option).RunInDir(dir) if err != nil { log.Error("%v - %s", err, out) } @@ -485,7 +485,7 @@ func serviceRPC(ctx gocontext.Context, h serviceHandler, service string) { } var stderr bytes.Buffer - cmd := git.NewCommandContext(h.r.Context(), service, "--stateless-rpc", h.dir) + cmd := git.NewCommand(h.r.Context(), service, "--stateless-rpc", h.dir) cmd.SetDescription(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir)) if err := cmd.RunWithContext(&git.RunContext{ Timeout: -1, @@ -525,7 +525,7 @@ func getServiceType(r *http.Request) string { } func updateServerInfo(ctx gocontext.Context, dir string) []byte { - out, err := git.NewCommandContext(ctx, "update-server-info").RunInDirBytes(dir) + out, err := git.NewCommand(ctx, "update-server-info").RunInDirBytes(dir) if err != nil { log.Error(fmt.Sprintf("%v - %s", err, string(out))) } @@ -555,7 +555,7 @@ func GetInfoRefs(ctx *context.Context) { } h.environ = append(os.Environ(), h.environ...) - refs, err := git.NewCommandContext(ctx, service, "--stateless-rpc", "--advertise-refs", ".").RunInDirTimeoutEnv(h.environ, -1, h.dir) + refs, err := git.NewCommand(ctx, service, "--stateless-rpc", "--advertise-refs", ".").RunInDirTimeoutEnv(h.environ, -1, h.dir) if err != nil { log.Error(fmt.Sprintf("%v - %s", err, string(refs))) } diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 0aea66ca67..9c575165a4 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -338,7 +338,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C } if commitSHA != "" { // Get immediate parent of the first commit in the patch, grab history back - parentCommit, err = git.NewCommandContext(ctx, "rev-list", "-1", "--skip=1", commitSHA).RunInDir(ctx.Repo.GitRepo.Path) + parentCommit, err = git.NewCommand(ctx, "rev-list", "-1", "--skip=1", commitSHA).RunInDir(ctx.Repo.GitRepo.Path) if err == nil { parentCommit = strings.TrimSpace(parentCommit) } |