6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-11 06:34:17 +00:00

Fix showing stdout of git commands

We need to capture also stderr because this is where eg, the progress of git clone is printed
This commit is contained in:
Grzegorz Dlugoszewski
2020-06-30 13:54:43 +02:00
parent fe35a7e493
commit d0797ad9b7

View File

@@ -76,16 +76,14 @@ func (c *Cmd) AndCaptureLine() (string, error) {
return lines[0], nil return lines[0], nil
} }
// AndShow executes the command and prints its output into standard output. // AndShow executes the command and prints its stderr and stdout.
func (c *Cmd) AndShow() error { func (c *Cmd) AndShow() error {
c.cmd.Stdout = os.Stdout c.cmd.Stdout = os.Stdout
c.cmd.Stderr = os.Stderr
errStream := &bytes.Buffer{}
c.cmd.Stderr = errStream
err := c.cmd.Run() err := c.cmd.Run()
if err != nil { if err != nil {
return &GitError{errStream, c.cmd.Args, err} return &GitError{&bytes.Buffer{}, c.cmd.Args, err}
} }
return nil return nil
} }