diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-07 21:59:36 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-04 09:07:15 +1100 |
commit | b4c078d565af69bcb2f46adc20e528e53ae32908 (patch) | |
tree | 7a336c0169b7eab49765d39f7a0dd5537e919ba2 /pkg/commands/loading_commits.go | |
parent | 157dd309f75f2ce3c23be53ddd2e4baa49a67321 (diff) |
WIP
Diffstat (limited to 'pkg/commands/loading_commits.go')
-rw-r--r-- | pkg/commands/loading_commits.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/pkg/commands/loading_commits.go b/pkg/commands/loading_commits.go index 204e4c9da..6f0935054 100644 --- a/pkg/commands/loading_commits.go +++ b/pkg/commands/loading_commits.go @@ -4,7 +4,6 @@ import ( "fmt" "io/ioutil" "os" - "os/exec" "path/filepath" "regexp" "strconv" @@ -153,9 +152,9 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit passedFirstPushedCommit = true } - cmd := c.getLogCmd(opts) + cmdObj := c.getLogCmd(opts) - err = oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) { + err = c.OSCommand.RunLineOutputCmd(cmdObj, func(line string) (bool, error) { if canExtractCommit(line) { commit := c.extractCommitFromLine(line) if commit.Sha == firstPushedCommit { @@ -201,7 +200,7 @@ func (c *CommitListBuilder) getHydratedRebasingCommits(rebaseMode string) ([]*mo // note that we're not filtering these as we do non-rebasing commits just because // I suspect that will cause some damage - cmd := c.OSCommand.ExecutableFromString( + cmdObj := c.OSCommand.NewCmdObj( fmt.Sprintf( "git show %s --no-patch --oneline %s --abbrev=%d", strings.Join(commitShas, " "), @@ -212,7 +211,7 @@ func (c *CommitListBuilder) getHydratedRebasingCommits(rebaseMode string) ([]*mo hydratedCommits := make([]*models.Commit, 0, len(commits)) i := 0 - err = oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) { + err = c.OSCommand.RunLineOutputCmd(cmdObj, func(line string) (bool, error) { if canExtractCommit(line) { commit := c.extractCommitFromLine(line) matchingCommit := commits[i] @@ -374,7 +373,7 @@ func (c *CommitListBuilder) getMergeBase(refName string) (string, error) { } // swallowing error because it's not a big deal; probably because there are no commits yet - output, _ := c.OSCommand.RunCommandWithOutput("git merge-base %s %s", c.OSCommand.Quote(refName), c.OSCommand.Quote(baseBranch)) + output, _ := c.OSCommand.RunWithOutput(c.OSCommand.NewCmdObj(fmt.Sprintf("git merge-base %s %s", c.OSCommand.Quote(refName), c.OSCommand.Quote(baseBranch)))) return ignoringWarnings(output), nil } @@ -391,7 +390,7 @@ func ignoringWarnings(commandOutput string) string { // getFirstPushedCommit returns the first commit SHA which has been pushed to the ref's upstream. // all commits above this are deemed unpushed and marked as such. func (c *CommitListBuilder) getFirstPushedCommit(refName string) (string, error) { - output, err := c.OSCommand.RunCommandWithOutput("git merge-base %s %s@{u}", c.OSCommand.Quote(refName), c.OSCommand.Quote(refName)) + output, err := c.OSCommand.RunWithOutput(c.OSCommand.NewCmdObj(fmt.Sprintf("git merge-base %s %s@{u}", c.OSCommand.Quote(refName), c.OSCommand.Quote(refName)))) if err != nil { return "", err } @@ -400,7 +399,7 @@ func (c *CommitListBuilder) getFirstPushedCommit(refName string) (string, error) } // getLog gets the git log. -func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) *exec.Cmd { +func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj { limitFlag := "" if opts.Limit { limitFlag = "-300" @@ -419,7 +418,7 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) *exec.Cmd { allFlag = " --all" } - return c.OSCommand.ExecutableFromString( + return c.OSCommand.NewCmdObj( fmt.Sprintf( "git log %s %s %s --oneline %s %s --abbrev=%d %s", c.OSCommand.Quote(opts.RefName), |