use go-cmd/cmd
This commit is contained in:
parent
ca00923762
commit
29551667f0
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
"github.com/go-cmd/cmd"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/repostatus"
|
||||
"go.wit.com/log"
|
||||
|
@ -110,8 +111,8 @@ func (r *RepoRow) IsPerfect() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (r *RepoRow) RunCmd(cmd []string) (error, string) {
|
||||
return r.Status.RunCmd(cmd)
|
||||
func (r *RepoRow) Run(cmd []string) cmd.Status {
|
||||
return r.Status.Run(cmd)
|
||||
}
|
||||
|
||||
func (r *RepoRow) AllTags() []*repostatus.Tag {
|
||||
|
|
|
@ -28,15 +28,15 @@ func (repo *RepoRow) GetPatches(oldname string, newname string) (int, []*Patch)
|
|||
// log.Info("repo userv, develv", userv, develv)
|
||||
gitcmd := []string{"git", "log", "--oneline", oldname + ".." + newname}
|
||||
log.Info("Run:", gitcmd)
|
||||
err, output := repo.Status.RunCmd(gitcmd)
|
||||
if err != nil {
|
||||
log.Info("git failed ", repo.GoPath(), "err =", err)
|
||||
r := repo.Status.Run(gitcmd)
|
||||
if r.Error != nil {
|
||||
log.Info("git failed ", repo.GoPath(), "err =", r.Error)
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// patches = strings.Split(output, "\n")
|
||||
log.Info("Run:", output)
|
||||
for _, line := range strings.Split(output, "\n") {
|
||||
log.Info("Run:", r.Stdout)
|
||||
for _, line := range r.Stdout {
|
||||
line = strings.TrimSpace(line)
|
||||
if line == "" {
|
||||
continue
|
||||
|
@ -98,9 +98,9 @@ func (r *RepoList) MakePatchset(setdir string) bool {
|
|||
// git format-patch branch1..branch2
|
||||
gitcmd := []string{"git", "format-patch", "-o", repodir, develn + ".." + usern}
|
||||
log.Info("Run:", gitcmd)
|
||||
err, output := repo.Status.RunCmd(gitcmd)
|
||||
log.Info("output =", output)
|
||||
if err == nil {
|
||||
r := repo.Status.Run(gitcmd)
|
||||
log.Info("output =", r.Stdout)
|
||||
if r.Error == nil {
|
||||
log.Info("patches made okay for:", repo.GoPath())
|
||||
continue
|
||||
}
|
||||
|
|
10
human.go
10
human.go
|
@ -51,14 +51,14 @@ func (v *RepoList) PrintReport(readonly string, onlydirty string, perfect string
|
|||
header := repo.StandardHeader()
|
||||
if onlydirty == "true" {
|
||||
if repo.CheckDirty() {
|
||||
log.Info(header+"")
|
||||
log.Info(header + "")
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if repo.ReadOnly() {
|
||||
if readonly == "true" {
|
||||
log.Info(header+"readonly")
|
||||
log.Info(header + "readonly")
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -68,14 +68,14 @@ func (v *RepoList) PrintReport(readonly string, onlydirty string, perfect string
|
|||
}
|
||||
}
|
||||
if repo.State() != "merge to main" {
|
||||
log.Info(header+"")
|
||||
log.Info(header + "")
|
||||
continue
|
||||
}
|
||||
if repo.CheckDirty() {
|
||||
log.Info(header+"")
|
||||
log.Info(header + "")
|
||||
continue
|
||||
}
|
||||
log.Info(header+"")
|
||||
log.Info(header + "")
|
||||
}
|
||||
log.Info(fmt.Sprintf("EVERYTHING WORKED repo count = %d", count))
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.wit.com/lib/protobuf/virtbuf"
|
||||
)
|
||||
|
||||
|
|
|
@ -138,14 +138,14 @@ func (r *RepoList) makeAutotypistView(newRepo *RepoRow) {
|
|||
}
|
||||
r.reposbox.Disable()
|
||||
// restore anything staged so everything can be reviewed
|
||||
newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRepo.Status.Run([]string{"git", "restore", "--staged", "."})
|
||||
newRepo.Status.XtermWait("git diff")
|
||||
newRepo.Status.XtermWait("git add --all")
|
||||
newRepo.Status.XtermWait("git commit -a")
|
||||
newRepo.Status.XtermWait("git push")
|
||||
if newRepo.Status.CheckDirty() {
|
||||
// commit was not done, restore diff
|
||||
newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRepo.Status.Run([]string{"git", "restore", "--staged", "."})
|
||||
} else {
|
||||
newRepo.NewScan()
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ func (r *RepoList) selectRepoAll() []*RepoRow {
|
|||
return repoPointers
|
||||
}
|
||||
|
||||
// this sort doesn't really work. I think it forgets to sort the last two
|
||||
// todo: sort this out. literally
|
||||
// SelectRepoPointers safely returns a slice of pointers to Repo records.
|
||||
func (r *RepoList) selectUnmergedRepos() []*RepoRow {
|
||||
r.RLock()
|
||||
|
|
|
@ -76,14 +76,14 @@ func (r *RepoList) ShowRepo(repo *RepoRow) error {
|
|||
return
|
||||
}
|
||||
// restore anything staged so everything can be reviewed
|
||||
newRow.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRow.Status.Run([]string{"git", "restore", "--staged", "."})
|
||||
newRow.Status.XtermWait("git diff")
|
||||
newRow.Status.XtermWait("git add --all")
|
||||
newRow.Status.XtermWait("git commit -a")
|
||||
newRow.Status.XtermWait("git push")
|
||||
if newRow.Status.CheckDirty() {
|
||||
// commit was not done, restore diff
|
||||
newRow.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRow.Status.Run([]string{"git", "restore", "--staged", "."})
|
||||
} else {
|
||||
newRow.NewScan()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue