diff --git a/submitPatches.go b/submitPatches.go index 17b63cb..485e0bf 100644 --- a/submitPatches.go +++ b/submitPatches.go @@ -7,17 +7,18 @@ import ( "go.wit.com/gui" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/repolist" - "go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/shell" "go.wit.com/log" ) +/* type patch struct { ref string giturl string comment string rs *repostatus.RepoStatus } +*/ type patchSummary struct { grid *gui.Node @@ -45,7 +46,7 @@ type patchSummary struct { unknownSubmitB *gui.Node reason *gadgets.BasicEntry submitB *gui.Node - allp []*patch + allp []*repolist.Patch } func submitPatchesBox(box *gui.Node) *patchSummary { @@ -55,12 +56,30 @@ func submitPatchesBox(box *gui.Node) *patchSummary { s.grid.NewButton("List Patches", func() { for i, p := range s.allp { - log.Info(i, p.ref, p.rs.String()) + log.Info(i, p.Ref, p.RS.String()) } // update the stats s.Update() }) + s.grid.NewButton("GetPatches()", func() { + var count int + for _, repo := range repolist.AllRepos() { + // if repo.GoPath() == "go.wit.com/apps/guireleaser" { + // repo.GetUserPatches() + if repo.ReadOnly() { + continue + } + //if repo.IsDirty() { + // continue + //} + c, _ := repo.GetMasterPatches() + count += c + // } + } + s.totalMasterPatches.SetText(strconv.Itoa(count) + " patches") + }) + s.gitPullB = s.grid.NewButton("git pull", func() { me.Disable() defer me.Enable() @@ -219,8 +238,6 @@ func submitPatchesBox(box *gui.Node) *patchSummary { log.Info("something went wrong making", patchdir) return } - // if makePatchset(patchdir) { - // } }) // disable these until there are not dirty repos s.reason.Disable() @@ -271,88 +288,4 @@ func (s *patchSummary) Update() { s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos") s.totalDevelRepos.SetText(strconv.Itoa(develT) + " repos") s.totalMasterRepos.SetText(strconv.Itoa(masterT) + " repos") - - /* move all this to repolist and gowit repos - p, allp := s.GetPatches() - if s.allp == nil { - s.allp = make([]*patch, 0, 0) - s.allp = append(s.allp, allp...) - } - if dirty == 0 { - s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches") - 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") - } - */ } - -// move all this to repolist and gowit repos - -/* -func (s *patchSummary) GetPatches() (int, []*patch) { - var patchcount int - patches := make([]*patch, 0, 0) - for _, repo := range repolist.AllRepos() { - // git log --oneline devel..jcarr - userv := repo.GetUserVersion() - develv := repo.GetDevelVersion() - usern := repo.GetUserBranchName() - develn := repo.GetDevelBranchName() - if userv == develv { - // log.Info("skipping unchanged repo", repo.String()) - } else { - // log.Info("repo userv, develv", userv, develv) - gitcmd := []string{"git", "log", "--oneline", develn + ".." + usern} - // log.Info("Run:", gitcmd) - err, output := repo.status.RunCmd(gitcmd) - if err == nil { - // patches := strings.Split(output, "\n") - for _, line := range strings.Split(output, "\n") { - parts := strings.Split(line, " ") - newp := new(patch) - newp.rs = repo.status - newp.ref = parts[0] - newp.comment = strings.Join(parts[1:], " ") - log.Info("patch:", line, newp.rs.String()) - patchcount += 1 - patches = append(patches, newp) - } - } else { - log.Info("git failed err=", err) - } - } - } - return patchcount, patches -} - -func makePatchset(setdir string) bool { - for _, repo := range me.allrepos { - userv := repo.status.GetUserVersion() - develv := repo.status.GetDevelVersion() - usern := repo.status.GetUserBranchName() - develn := repo.status.GetDevelBranchName() - if userv == develv { - // this repo is unchanged - continue - } - - repodir := filepath.Join(setdir, repo.String()) - shell.Mkdir(repodir) - // 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 { - log.Info("patches made okay for:", repo.String()) - continue - } - log.Info("patches failed for:", repo.String()) - return false - } - return true -} -*/