diff options
| author | Jeff Carr <[email protected]> | 2024-11-13 10:33:25 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-13 10:33:25 -0600 |
| commit | 009d8f3b9d743fb1fa891376d5c36290681e33f1 (patch) | |
| tree | 54723bd0cc8c681a65b3572cea9f721356b636d9 /git.go | |
| parent | 55acea0bd769132db7bf420fef3b94fa21ca5f83 (diff) | |
improve output handling via go-cmd
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'git.go')
| -rw-r--r-- | git.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -11,6 +11,7 @@ import ( "io/ioutil" "go.wit.com/log" + "go.wit.com/lib/gui/shell" ) func (rs *RepoStatus) GetCurrentBranchName() string { @@ -95,7 +96,7 @@ func (rs *RepoStatus) gitDescribeByHash(hash string) (string, error) { if hash == "" { return "", errors.New("hash was blank") } - r := rs.Run([]string{"git", "describe", "--tags", "--always", hash}) + r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always", hash}, INFO) out := strings.Join(r.Stdout, "\n") if r.Error != nil { log.Warn("not in a git repo or bad hash?", r.Error, rs.Path()) @@ -109,7 +110,7 @@ func (rs *RepoStatus) gitDescribeByName(name string) (string, error) { if name == "" { // git will return the current tag - r := rs.Run([]string{"git", "describe", "--tags", "--always"}) + r := shell.PathRunLog(rs.Path(), []string{"git", "describe", "--tags", "--always"}, INFO) output := strings.Join(r.Stdout, "\n") if r.Error != nil { log.Warn("gitDescribeByName() not in a git repo?", r.Error, rs.Path()) @@ -121,7 +122,7 @@ func (rs *RepoStatus) gitDescribeByName(name string) (string, error) { return "", errors.New("gitDescribeByName() git fatal: Not a valid object name") } cmd := []string{"git", "describe", "--tags", "--always", name} - r := rs.Run(cmd) + r := shell.PathRunLog(rs.Path(), cmd, INFO) output := strings.Join(r.Stdout, "\n") if r.Error != nil { log.Warn("cmd =", cmd) @@ -211,7 +212,7 @@ func (rs *RepoStatus) DirtyList() []string { func (rs *RepoStatus) CheckDirty() bool { var start string = rs.dirtyLabel.String() cmd := []string{"git", "status", "--porcelain"} - r := rs.Run(cmd) + r := shell.PathRunLog(rs.Path(), cmd, INFO) out := strings.Join(r.Stdout, "\n") if r.Error != nil { log.Warn("CheckDirty() status cmd =", cmd) @@ -571,7 +572,7 @@ func (rs *RepoStatus) CheckBranches() bool { } var cmd []string cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash) - r := rs.Run(cmd) + r := shell.PathRunLog(rs.Path(), cmd, INFO) if r.Error != nil { log.Log(WARN, "CheckBranches() git show error:", r.Error) } |
