refactor: remove Ctx field from git.Repository (#38500)

This commit is contained in:
wxiaoguang
2026-07-17 18:44:31 +08:00
committed by GitHub
parent 2c8e99bbf7
commit 5b078f72aa
235 changed files with 1234 additions and 1258 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ package git
import (
"bytes"
"context"
"os"
"strings"
"time"
@@ -23,7 +24,7 @@ type CommitTreeOpts struct {
}
// CommitTree creates a commit from a given tree id for the user with provided message
func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opts CommitTreeOpts) (ObjectID, error) {
func (repo *Repository) CommitTree(ctx context.Context, author, committer *Signature, tree *Tree, opts CommitTreeOpts) (ObjectID, error) {
commitTimeStr := time.Now().Format(time.RFC3339)
// Because this may call hooks we should pass in the environment
@@ -61,7 +62,7 @@ func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opt
stdout, _, err := cmd.WithEnv(env).
WithDir(repo.Path).
WithStdinBytes(messageBytes.Bytes()).
RunStdString(repo.Ctx)
RunStdString(ctx)
if err != nil {
return nil, err
}