diff options
Diffstat (limited to 'pkg/commands/git.go')
-rw-r--r-- | pkg/commands/git.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 8750ecf51..7d4cc6c86 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -223,22 +223,22 @@ func findDotGitDir(stat func(string) (os.FileInfo, error), readFile func(filenam } func VerifyInGitRepo(osCommand *oscommands.OSCommand) error { - return osCommand.RunCommand("git rev-parse --git-dir") + return osCommand.Run(osCommand.NewCmdObj("git rev-parse --git-dir")) } -func (c *GitCommand) RunCommand(formatString string, formatArgs ...interface{}) error { - _, err := c.RunCommandWithOutput(formatString, formatArgs...) +func (c *GitCommand) Run(cmdObj oscommands.ICmdObj) error { + _, err := c.RunWithOutput(cmdObj) return err } -func (c *GitCommand) RunCommandWithOutput(formatString string, formatArgs ...interface{}) (string, error) { +func (c *GitCommand) RunWithOutput(cmdObj oscommands.ICmdObj) (string, error) { // TODO: have this retry logic in other places we run the command waitTime := 50 * time.Millisecond retryCount := 5 attempt := 0 for { - output, err := c.OSCommand.RunCommandWithOutput(formatString, formatArgs...) + output, err := c.OSCommand.RunWithOutput(cmdObj) if err != nil { // if we have an error based on the index lock, we should wait a bit and then retry if strings.Contains(output, ".git/index.lock") { @@ -255,6 +255,12 @@ func (c *GitCommand) RunCommandWithOutput(formatString string, formatArgs ...int } } -func (c *GitCommand) NewCmdObjFromStr(cmdStr string) oscommands.ICmdObj { - return c.OSCommand.NewCmdObjFromStr(cmdStr).AddEnvVars("GIT_OPTIONAL_LOCKS=0") +func (c *GitCommand) NewCmdObj(cmdStr string) oscommands.ICmdObj { + return c.OSCommand.NewCmdObj(cmdStr).AddEnvVars("GIT_OPTIONAL_LOCKS=0") +} + +func (c *GitCommand) NewCmdObjWithLog(cmdStr string) oscommands.ICmdObj { + cmdObj := c.NewCmdObj(cmdStr) + c.OSCommand.LogCmdObj(cmdObj) + return cmdObj } |