mirror of
https://github.com/go-gitea/gitea.git
synced 2025-09-21 17:48:15 +00:00
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:
@@ -11,12 +11,13 @@ import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/git/gitcmd"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// ResolveReference resolves a name to a reference
|
||||
func (repo *Repository) ResolveReference(name string) (string, error) {
|
||||
stdout, _, err := NewCommand("show-ref", "--hash").AddDynamicArguments(name).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
|
||||
stdout, _, err := gitcmd.NewCommand("show-ref", "--hash").AddDynamicArguments(name).RunStdString(repo.Ctx, &gitcmd.RunOpts{Dir: repo.Path})
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not a valid ref") {
|
||||
return "", ErrNotExist{name, ""}
|
||||
@@ -52,13 +53,13 @@ func (repo *Repository) GetRefCommitID(name string) (string, error) {
|
||||
|
||||
// SetReference sets the commit ID string of given reference (e.g. branch or tag).
|
||||
func (repo *Repository) SetReference(name, commitID string) error {
|
||||
_, _, err := NewCommand("update-ref").AddDynamicArguments(name, commitID).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
|
||||
_, _, err := gitcmd.NewCommand("update-ref").AddDynamicArguments(name, commitID).RunStdString(repo.Ctx, &gitcmd.RunOpts{Dir: repo.Path})
|
||||
return err
|
||||
}
|
||||
|
||||
// RemoveReference removes the given reference (e.g. branch or tag).
|
||||
func (repo *Repository) RemoveReference(name string) error {
|
||||
_, _, err := NewCommand("update-ref", "--no-deref", "-d").AddDynamicArguments(name).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
|
||||
_, _, err := gitcmd.NewCommand("update-ref", "--no-deref", "-d").AddDynamicArguments(name).RunStdString(repo.Ctx, &gitcmd.RunOpts{Dir: repo.Path})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ func (repo *Repository) IsCommitExist(name string) bool {
|
||||
log.Error("IsCommitExist: %v", err)
|
||||
return false
|
||||
}
|
||||
_, _, err := NewCommand("cat-file", "-e").AddDynamicArguments(name).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
|
||||
_, _, err := gitcmd.NewCommand("cat-file", "-e").AddDynamicArguments(name).RunStdString(repo.Ctx, &gitcmd.RunOpts{Dir: repo.Path})
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user