提交 4cb663a9 编写于 作者: J Jingwen Owen Ou

Rename `Cmd.ExecOutput` to `Cmd.CombinedOutput` to avoid confusion

We now have `Cmd.Spawn` and `Cmd.Exec`, to avoid confusion, we use `Cmd.CombinedOutput` for combined output.
上级 0ed14758
...@@ -37,7 +37,7 @@ func (cmd *Cmd) WithArgs(args ...string) *Cmd { ...@@ -37,7 +37,7 @@ func (cmd *Cmd) WithArgs(args ...string) *Cmd {
return cmd return cmd
} }
func (cmd *Cmd) ExecOutput() (string, error) { func (cmd *Cmd) CombinedOutput() (string, error) {
output, err := exec.Command(cmd.Name, cmd.Args...).CombinedOutput() output, err := exec.Command(cmd.Name, cmd.Args...).CombinedOutput()
return string(output), err return string(output), err
......
...@@ -48,7 +48,7 @@ func (r *TestRepo) Setup() { ...@@ -48,7 +48,7 @@ func (r *TestRepo) Setup() {
func (r *TestRepo) clone(repo, dir string) error { func (r *TestRepo) clone(repo, dir string) error {
cmd := cmd.New("git").WithArgs("clone", repo, dir) cmd := cmd.New("git").WithArgs("clone", repo, dir)
output, err := cmd.ExecOutput() output, err := cmd.CombinedOutput()
if err != nil { if err != nil {
err = fmt.Errorf("error cloning %s to %s: %s", repo, dir, output) err = fmt.Errorf("error cloning %s to %s: %s", repo, dir, output)
} }
......
...@@ -130,7 +130,7 @@ func Show(sha string) (string, error) { ...@@ -130,7 +130,7 @@ func Show(sha string) (string, error) {
cmd := cmd.New("git") cmd := cmd.New("git")
cmd.WithArg("show").WithArg("-s").WithArg("--format=%s%n%+b").WithArg(sha) cmd.WithArg("show").WithArg("-s").WithArg("--format=%s%n%+b").WithArg(sha)
output, err := cmd.ExecOutput() output, err := cmd.CombinedOutput()
output = strings.TrimSpace(output) output = strings.TrimSpace(output)
return output, err return output, err
...@@ -144,7 +144,7 @@ func Log(sha1, sha2 string) (string, error) { ...@@ -144,7 +144,7 @@ func Log(sha1, sha2 string) (string, error) {
shaRange := fmt.Sprintf("%s...%s", sha1, sha2) shaRange := fmt.Sprintf("%s...%s", sha1, sha2)
execCmd.WithArg(shaRange) execCmd.WithArg(shaRange)
outputs, err := execCmd.ExecOutput() outputs, err := execCmd.CombinedOutput()
if err != nil { if err != nil {
return "", fmt.Errorf("Can't load git log %s..%s", sha1, sha2) return "", fmt.Errorf("Can't load git log %s..%s", sha1, sha2)
} }
...@@ -207,7 +207,7 @@ func execGitCmd(input ...string) (outputs []string, err error) { ...@@ -207,7 +207,7 @@ func execGitCmd(input ...string) (outputs []string, err error) {
cmd.WithArg(i) cmd.WithArg(i)
} }
out, err := cmd.ExecOutput() out, err := cmd.CombinedOutput()
for _, line := range strings.Split(out, "\n") { for _, line := range strings.Split(out, "\n") {
line = strings.TrimSpace(line) line = strings.TrimSpace(line)
if line != "" { if line != "" {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册