use go-cmd/cmd

This commit is contained in:
Jeff Carr 2024-11-08 06:41:47 -06:00
parent b33280b869
commit 169d2127da
2 changed files with 14 additions and 20 deletions

View File

@ -122,7 +122,7 @@ func (r *repoWindow) repoMenu() *gui.Node {
r.Disable() r.Disable()
defer r.Enable() defer r.Enable()
for _, repo := range r.View.AllRepos() { for _, repo := range r.View.AllRepos() {
repo.RunCmd([]string{"git", "pull"}) repo.Run([]string{"git", "pull"})
} }
}) })

View File

@ -1,21 +1,14 @@
package main package main
import ( import (
"go.wit.com/log" "strings"
"go.wit.com/lib/gui/repostatus" "go.wit.com/log"
"go.wit.com/lib/gui/shell"
) )
// only errors on bad errors // only errors on bad errors
func quickCmd(fullpath string, cmd []string) bool { func quickCmd(fullpath string, cmd []string) bool {
var err error
var b bool
var output string
// if me.autoWorkingPwd.String() != fullpath {
// me.autoWorkingPwd.SetValue(fullpath)
// }
if me.autoDryRun.Checked() { if me.autoDryRun.Checked() {
log.Warn("RUN --dry-run", fullpath, cmd) log.Warn("RUN --dry-run", fullpath, cmd)
return false return false
@ -23,18 +16,19 @@ func quickCmd(fullpath string, cmd []string) bool {
log.Warn("RUN:", fullpath, cmd) log.Warn("RUN:", fullpath, cmd)
} }
err, b, output = repostatus.RunCmd(fullpath, cmd) r := shell.PathRun(fullpath, cmd)
if err != nil { output := strings.TrimSpace(strings.Join(r.Stdout, "\n"))
if r.Error != nil {
log.Warn("cmd =", cmd) log.Warn("cmd =", cmd)
log.Warn("err =", err) log.Warn("err =", r.Error)
log.Warn("b =", b) log.Warn("b =", r.Exit)
log.Warn("output =", string(output)) log.Warn("output =", output)
return false return false
} else if !b { } else if r.Exit != 0 {
log.Warn("b =", b) log.Warn("b =", r.Exit)
log.Warn("output =", string(output)) log.Warn("output =", output)
return true return true
} }
log.Warn("output = ", string(output)) log.Warn("output = ", output)
return true return true
} }