Move git command to git/gitcmd (#35483)

The name cmd is already used in many places and may cause conflicts, so
I chose `gitcmd` instead to minimize potential naming conflicts.
This commit is contained in:
Lunny Xiao
2025-09-15 23:33:12 -07:00
committed by GitHub
parent fe5afcb022
commit 9332ff291b
107 changed files with 690 additions and 558 deletions

View File

@@ -9,6 +9,8 @@ import (
"os"
"strings"
"time"
"code.gitea.io/gitea/modules/git/gitcmd"
)
// CommitTreeOpts represents the possible options to CommitTree
@@ -33,7 +35,7 @@ func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opt
"GIT_COMMITTER_EMAIL="+committer.Email,
"GIT_COMMITTER_DATE="+commitTimeStr,
)
cmd := NewCommand("commit-tree").AddDynamicArguments(tree.ID.String())
cmd := gitcmd.NewCommand("commit-tree").AddDynamicArguments(tree.ID.String())
for _, parent := range opts.Parents {
cmd.AddArguments("-p").AddDynamicArguments(parent)
@@ -58,7 +60,7 @@ func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opt
stdout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
err := cmd.Run(repo.Ctx, &RunOpts{
err := cmd.Run(repo.Ctx, &gitcmd.RunOpts{
Env: env,
Dir: repo.Path,
Stdin: messageBytes,
@@ -66,7 +68,7 @@ func (repo *Repository) CommitTree(author, committer *Signature, tree *Tree, opt
Stderr: stderr,
})
if err != nil {
return nil, ConcatenateError(err, stderr.String())
return nil, gitcmd.ConcatenateError(err, stderr.String())
}
return NewIDFromString(strings.TrimSpace(stdout.String()))
}