diff --git a/repolist.go b/repolist.go index 61a53f4..0f05bbc 100644 --- a/repolist.go +++ b/repolist.go @@ -145,6 +145,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri newRepo.status.Xterm([]string{"git add --all"}) newRepo.status.XtermNohup([]string{"git diff --cached"}) newRepo.status.Xterm([]string{"git commit -a"}) + newRepo.status.Xterm([]string{"git push"}) if newRepo.status.CheckDirty() { // commit was not done, restore diff newRepo.status.Xterm([]string{"git restore --staged ."}) diff --git a/submitPatches.go b/submitPatches.go index 32bedff..e612ded 100644 --- a/submitPatches.go +++ b/submitPatches.go @@ -18,11 +18,13 @@ type patch struct { rs *repostatus.RepoStatus } - type patchSummary struct { - grid *gui.Node - updateB *gui.Node - docsB *gui.Node + grid *gui.Node + updateB *gui.Node + docsB *gui.Node + gitPushB *gui.Node + gitPullB *gui.Node + checkB *gui.Node totalOL *gadgets.OneLiner dirtyOL *gadgets.OneLiner @@ -49,30 +51,78 @@ func submitPatchesBox(box *gui.Node) *patchSummary { s.Update() }) - s.updateB = s.grid.NewButton("List Patches", func() { + s.grid.NewButton("List Patches", func() { for i, p := range s.allp { log.Info(i, p.ref, p.rs.String()) } }) - s.updateB = s.grid.NewButton("Check repos are working", func() { + s.gitPullB = s.grid.NewButton("git pull", func() { me.Disable() defer me.Enable() for _, repo := range me.allrepos { - // log.Info("Check repo here:", repo.String()) - ok, giturl := gowit.CheckRegistered(repo.status) - if ok { - log.Info("is url correct?", repo.String(), "vs", giturl) - repo.giturl = giturl + // gitcmd := []string{"git", "fetch", "origin"} + gitcmd := []string{"git", "pull"} + err, output := repo.status.RunCmd(gitcmd) + log.Info("output =", output) + if err == nil { + log.Info("git fetch worked", repo.String()) } else { - log.Info("repo check failed", repo.String()) - repo.giturl = "look in .git/config" - s.unknownOL.SetText(repo.String()) - s.unknownOL.Show() - s.unknownSubmitB.Show() + log.Info("git fetch failed", repo.String()) return } } + s.gitPullB.SetText("GOOD") + }) + + s.gitPushB = s.grid.NewButton("git push", func() { + me.Disable() + defer me.Enable() + for _, repo := range me.allrepos { + gitcmd := []string{"git", "push"} + err, output := repo.status.RunCmd(gitcmd) + log.Info("output =", output) + if err == nil { + log.Info("git push worked", repo.String()) + } else { + log.Info("git push failed", repo.String()) + return + } + } + s.gitPushB.SetText("GOOD") + }) + + s.checkB = s.grid.NewButton("Check repos are working", func() { + me.Disable() + defer me.Enable() + for _, repo := range me.allrepos { + if repo.giturl != "" { + log.Info("repo already checked. do they match?", repo.String()) + log.Info("go.wit.com =", repo.giturl) + log.Info("localurl =", repo.status.GitURL()) + } else { + ok, giturl := gowit.CheckRegistered(repo.status) + if ok { + log.Info("is url correct?", repo.String(), "vs", giturl) + repo.giturl = giturl + if giturl != repo.status.GitURL() { + log.Info("repo check failed", repo.String()) + s.unknownOL.SetText(repo.String()) + s.unknownOL.Show() + s.unknownSubmitB.Show() + return + } + } else { + log.Info("repo check failed", repo.String()) + repo.giturl = "look in .git/config" + s.unknownOL.SetText(repo.String()) + s.unknownOL.Show() + s.unknownSubmitB.Show() + return + } + } + } + s.checkB.SetText("GOOD") }) s.grid.NextRow() @@ -94,7 +144,7 @@ func submitPatchesBox(box *gui.Node) *patchSummary { } } } else { - log.Info("what is this?", s.unknownOL.String()) + log.Info("what is this?", s.unknownOL.String()) } }) s.unknownOL.Hide() @@ -155,8 +205,9 @@ func (s *patchSummary) Update() { } if dirty == 0 { s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches") - s.submitB.Enable() s.reason.Enable() + // force the user to submit a reason to enable the submit button + // s.submitB.Enable() } else { s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches + ? dirty") }