Skip to content

Commit

Permalink
rough debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Aug 15, 2022
1 parent 9427b54 commit 9012405
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"errors"
"fmt"
"io"
"log"
"os/exec"
"regexp"
"strings"
)

func git(args ...string) (string, string, error) {
log.Println(args)
var (
outBuf bytes.Buffer
errBuf bytes.Buffer
Expand All @@ -19,6 +21,12 @@ func git(args ...string) (string, string, error) {
cmd.Stdout = &outBuf
cmd.Stderr = &errBuf
err := cmd.Run()

if err != nil {
log.Println(err)
log.Println(outBuf.String())
log.Println(errBuf.String())
}
return strings.TrimSpace(outBuf.String()), strings.TrimSpace(errBuf.String()), err
}

Expand All @@ -29,6 +37,7 @@ type cmd struct {
}

func (c *cmd) git(args ...string) (string, string) {
log.Println(args)
return c.run("git", args...)
}

Expand All @@ -47,6 +56,11 @@ func (c *cmd) run(prog string, args ...string) (string, string) {
cmd.Dir = c.dir
}
c.err = cmd.Run()
if c.err != nil {
log.Println(c.err)
log.Println(outBuf.String())
log.Println(errBuf.String())
}
return outBuf.String(), errBuf.String()
}

Expand Down

0 comments on commit 9012405

Please sign in to comment.