summaryrefslogtreecommitdiff
path: root/submitPatches.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-17 08:38:44 -0600
committerJeff Carr <[email protected]>2024-02-17 08:38:44 -0600
commitdfc28a04d637d9af6eef8bde9b65952b99b15465 (patch)
tree9bc0d9080e1633b4d0af16731f263eecf40faa05 /submitPatches.go
parent9cce297abf9ac75bcb467602ceae16b67c80ef25 (diff)
refactor to use repolist package
Diffstat (limited to 'submitPatches.go')
-rw-r--r--submitPatches.go116
1 files changed, 62 insertions, 54 deletions
diff --git a/submitPatches.go b/submitPatches.go
index ee4051b..b835b6f 100644
--- a/submitPatches.go
+++ b/submitPatches.go
@@ -3,11 +3,10 @@ package main
import (
"path/filepath"
"strconv"
- "strings"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
- "go.wit.com/lib/gui/gowit"
+ "go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
@@ -58,10 +57,10 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
s.gitPullB = s.grid.NewButton("git pull", func() {
me.Disable()
defer me.Enable()
- for _, repo := range me.allrepos {
+ for _, repo := range repolist.AllRepos() {
// gitcmd := []string{"git", "fetch", "origin"}
gitcmd := []string{"git", "pull"}
- err, output := repo.status.RunCmd(gitcmd)
+ err, output := repo.RunCmd(gitcmd)
log.Info("output =", output)
if err == nil {
log.Info("git fetch worked", repo.String())
@@ -78,9 +77,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
s.gitPushB = s.grid.NewButton("git push", func() {
me.Disable()
defer me.Enable()
- for _, repo := range me.allrepos {
+ for _, repo := range repolist.AllRepos() {
gitcmd := []string{"git", "push"}
- err, output := repo.status.RunCmd(gitcmd)
+ err, output := repo.RunCmd(gitcmd)
log.Info("output =", output)
if err == nil {
log.Info("git push worked", repo.String())
@@ -95,59 +94,62 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
})
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() {
+ /*
+ me.Disable()
+ defer me.Enable()
+ for _, repo := range repolist.AllRepos() {
+ if repo.GitURL() != "" {
+ log.Info("repo already checked. do they match?")
+ log.Info("go.wit.com =", repo.GoURL())
+ log.Info("localurl =", repo.Path())
+ } else {
+ ok, giturl := gowit.CheckRegistered(repo)
+ if ok {
+ log.Info("is url correct?", repo.Path(), "vs", giturl)
+ repo.giturl = giturl
+ if giturl != repo.Path() {
+ 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
}
- } 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.checkB.SetText("GOOD")
+ */
})
s.grid.NextRow()
s.unknownOL = gadgets.NewOneLiner(s.grid, "Unknown Repo:")
s.unknownSubmitB = s.grid.NewButton("Register Repo", func() {
- log.Info("Submit repo:", s.unknownOL.String())
- repo, ok := me.allrepos[s.unknownOL.String()]
- if ok {
- log.Info("found repo:", repo.String(), "with giturl", repo.giturl)
- localurl := repo.status.GitURL()
- if localurl == "" {
- log.Info("local repo check failed. repo is not uploaded?")
- } else {
- log.Info("local repo has", localurl)
- // attempts to register the unknown repo
- if gowit.Register(repo.String(), localurl) {
- s.unknownOL.Hide()
- s.unknownSubmitB.Hide()
+ /*
+ log.Info("Submit repo:", s.unknownOL.String())
+ if repolist.Exists(s.unknownOL.String()) {
+ log.Info("found repo:", repo.String(), "with giturl", repo.giturl)
+ localurl := repo.status.GitURL()
+ if localurl == "" {
+ log.Info("local repo check failed. repo is not uploaded?")
+ } else {
+ log.Info("local repo has", localurl)
+ // attempts to register the unknown repo
+ if gowit.Register(repo.String(), localurl) {
+ s.unknownOL.Hide()
+ s.unknownSubmitB.Hide()
+ }
}
+ } else {
+ log.Info("what is this?", s.unknownOL.String())
}
- } else {
- log.Info("what is this?", s.unknownOL.String())
- }
+ */
})
s.unknownOL.Hide()
s.unknownSubmitB.Hide()
@@ -185,8 +187,8 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
log.Info("something went wrong making", patchdir)
return
}
- if makePatchset(patchdir) {
- }
+ // if makePatchset(patchdir) {
+ // }
})
// disable these until there are not dirty repos
s.reason.Disable()
@@ -197,9 +199,9 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
func (s *patchSummary) Update() {
var total, dirty, readonly int
- for _, repo := range me.allrepos {
+ for _, repo := range repolist.AllRepos() {
total += 1
- if repo.status.CheckDirty() {
+ if repo.IsDirty() {
if repo.String() == "go.wit.com/apps/autotypist" {
// log.Info("ignoring dirty autotypist for now")
dirty += 1
@@ -207,7 +209,7 @@ func (s *patchSummary) Update() {
dirty += 1
}
}
- if repo.status.ReadOnly() {
+ if repo.ReadOnly() {
readonly += 1
}
}
@@ -215,6 +217,7 @@ func (s *patchSummary) Update() {
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
+ /* move all this to repolist and gowit repos
p, allp := s.GetPatches()
if s.allp == nil {
s.allp = make([]*patch, 0, 0)
@@ -228,17 +231,21 @@ func (s *patchSummary) Update() {
} 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 me.allrepos {
+ for _, repo := range repolist.AllRepos() {
// git log --oneline devel..jcarr
- userv := repo.status.GetUserVersion()
- develv := repo.status.GetDevelVersion()
- usern := repo.status.GetUserBranchName()
- develn := repo.status.GetDevelBranchName()
+ userv := repo.GetUserVersion()
+ develv := repo.GetDevelVersion()
+ usern := repo.GetUserBranchName()
+ develn := repo.GetDevelBranchName()
if userv == develv {
// log.Info("skipping unchanged repo", repo.String())
} else {
@@ -293,3 +300,4 @@ func makePatchset(setdir string) bool {
}
return true
}
+*/