start deprecating me.found

This commit is contained in:
Jeff Carr 2025-02-21 18:31:26 -06:00
parent 66e65c7a00
commit 1a255bdbf6
9 changed files with 45 additions and 49 deletions

View File

@ -32,7 +32,7 @@ install-raw: goimports vet plugin
plugin:
rm -f resources/*.so
-cp ../../toolkits/gocui/gocui.so resources/
# -cp ../../toolkits/gocui/gocui.so resources/
andlabs: install
forge --gui andlabs --debugger

View File

@ -51,9 +51,8 @@ func IsAnythingDirty() bool {
me.found = new(gitpb.Repos)
findAll() // select all the repos
doCheckDirtyAndConfigSave()
me.found = new(gitpb.Repos)
findDirty()
if len(me.found.Repos) == 0 {
found := findDirty()
if found.Len() == 0 {
return false
} else {
return true

View File

@ -15,9 +15,8 @@ func doCommit() {
if argv.All {
log.Info("do a commit everywhere")
doCheckDirtyAndConfigSave()
me.found = new(gitpb.Repos)
findDirty()
all := me.found.All()
found := findDirty()
all := found.All()
for all.Scan() {
repo := all.Next()
log.Info("do a commit on repo", repo.GetGoPath())

View File

@ -14,12 +14,11 @@ import (
func doDirty() {
findAll() // select all the repos
doCheckDirtyAndConfigSave()
me.found = new(gitpb.Repos)
findDirty()
found := findDirty()
if argv.Verbose {
me.forge.PrintHumanTableDirty(me.found)
me.forge.PrintHumanTableDirty(found)
} else {
me.forge.PrintHumanTable(me.found)
me.forge.PrintHumanTable(found)
}
}
@ -51,15 +50,7 @@ func doCheckDirty(repo *gitpb.Repo) error {
func doCheckDirtyAndConfigSave() {
start := straightCheckDirty()
// log.Info("before findAll()")
/*
all := me.found.All()
for all.Scan() {
repo := all.Next()
repo.CheckDirty()
}
*/
// this might work?
now := time.Now()
me.forge.RillFuncError(doCheckDirty)
end := straightCheckDirty()

View File

@ -21,7 +21,7 @@ import (
)
func debug() {
time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)
for {
now := time.Now()
tmp := fmt.Sprintf("All (%d)", me.forge.Repos.Len())
@ -45,8 +45,9 @@ func debug() {
tmp = fmt.Sprintf("writable (%d)", me.found.Len())
me.repoWritableB.SetLabel(tmp)
doDirty()
tmp = fmt.Sprintf("dirty (%d)", me.found.Len())
doCheckDirtyAndConfigSave()
found := findDirty()
tmp = fmt.Sprintf("dirty (%d)", found.Len())
me.repoDirtyB.SetLabel(tmp)
log.Printf("finished a forge scan here in (%s)\n", shell.FormatDuration(time.Since(now)))
@ -197,9 +198,19 @@ func drawWindow(win *gadgets.BasicWindow) {
grid = group2.RawGrid()
me.repoDirtyB = grid.NewButton("dirty", func() {
me.found = new(gitpb.Repos)
findDirty()
makeStandardReposWindow("dirty repos", me.found)
doCheckDirtyAndConfigSave()
found := findDirty()
_, box := makeStandardReposWindow("dirty repos", found)
box.NewButton("commit all", func() {
all := found.SortByFullPath()
for all.Scan() {
repo := all.Next()
log.Info("do commit here on", repo.GetGoPath())
}
log.Info("TODO: fix this")
log.Info("run 'forge commit --all'")
})
})
me.repoWritableB = grid.NewButton("writable", func() {
@ -360,7 +371,7 @@ func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable {
}
// this is the magic that generates a window directly from the protocol buffer
func makeStandardReposWindow(title string, pb *gitpb.Repos) *gitpb.ReposTable {
func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable, *gui.Node) {
win := gadgets.RawBasicWindow(title)
win.Make()
win.Show()
@ -373,7 +384,7 @@ func makeStandardReposWindow(title string, pb *gitpb.Repos) *gitpb.ReposTable {
t := makeStandardReposGrid(pb)
t.SetParent(box)
t.ShowTable()
return t
return t, box
}
func findMergeToDevel() {

24
find.go
View File

@ -14,43 +14,43 @@ import (
//
// by default, it adds every repo
func (f *FindCmd) findRepos() {
func (f *FindCmd) findRepos() *gitpb.Repos {
if f == nil {
findMine()
return
return me.found
}
if f.All {
findAll()
return
return me.found
}
if f.Private {
findPrivate()
return
return me.found
}
if f.Mine {
findMine()
return
return me.found
}
if f.Favorites {
findFavorites()
return
return me.found
}
if f.Dirty {
findDirty()
return
return findDirty()
}
if f.User {
findUser()
return
return me.found
}
findAll()
return me.found
}
func findPrivate() {
@ -89,15 +89,17 @@ func findFavorites() {
}
// finds repos that git is reporting as dirty
func findDirty() {
func findDirty() *gitpb.Repos {
found := gitpb.NewRepos()
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
var repo *gitpb.Repo
repo = all.Next()
if repo.IsDirty() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
return found
}
func findAll() {

View File

@ -152,21 +152,19 @@ func main() {
}
if argv.GitFetch != nil {
// argv.GitPull.findRepos()
doGitFetch()
okExit("")
}
if argv.GitPull != nil {
// argv.GitPull.findRepos()
doGitPullNew()
okExit("")
}
if argv.List != nil {
argv.List.findRepos()
found := argv.List.findRepos()
// print out the repos
me.forge.PrintHumanTable(me.found)
me.forge.PrintHumanTable(found)
okExit("")
}

View File

@ -62,9 +62,8 @@ func (r *foundWindow) initWindow() {
group1 := r.stack.NewGroup("Repo Summary")
group1.NewButton("dirty", func() {
log.Info("find dirty here")
me.found = new(gitpb.Repos)
findDirty()
me.forge.PrintHumanTable(me.found)
found := findDirty()
me.forge.PrintHumanTable(found)
})
group1.NewButton("all", func() {
log.Info("find all here")

View File

@ -99,9 +99,6 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
group.NewButton("hello", func() {
log.Info("world")
})
group.NewButton("list", func() {
log.Info("world")
})
t := makeStandardReposGrid(found)
t.SetParent(box)