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

@@ -8,6 +8,8 @@ import (
"bytes"
"io"
"strings"
"code.gitea.io/gitea/modules/git/gitcmd"
)
// ObjectType git object type
@@ -66,15 +68,15 @@ func (repo *Repository) HashObject(reader io.Reader) (ObjectID, error) {
}
func (repo *Repository) hashObject(reader io.Reader, save bool) (string, error) {
var cmd *Command
var cmd *gitcmd.Command
if save {
cmd = NewCommand("hash-object", "-w", "--stdin")
cmd = gitcmd.NewCommand("hash-object", "-w", "--stdin")
} else {
cmd = NewCommand("hash-object", "--stdin")
cmd = gitcmd.NewCommand("hash-object", "--stdin")
}
stdout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
err := cmd.Run(repo.Ctx, &RunOpts{
err := cmd.Run(repo.Ctx, &gitcmd.RunOpts{
Dir: repo.Path,
Stdin: reader,
Stdout: stdout,