show problem totals

This commit is contained in:
Jeff Carr 2025-02-21 10:21:13 -06:00
parent 76143a6474
commit 9cc63ce391
1 changed files with 86 additions and 17 deletions

View File

@ -4,6 +4,7 @@
package main
import (
"fmt"
"sync"
"go.wit.com/lib/gadgets"
@ -92,20 +93,14 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
}
makeStandardReposWindow(me.found)
})
var found *gitpb.Repos
var txt string
grid.NewButton("user branch is remote", func() {
log.Info("not done yet")
me.found = new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
username := repo.GetUserBranchName()
if repo.IsBranchRemote(username) {
me.found.AppendByGoPath(repo)
}
}
makeStandardReposWindow(me.found)
found = remoteUserBranchProblem()
txt = fmt.Sprintf("user branch is remote (%d)", found.Len())
grid.NewButton(txt, func() {
found := remoteUserBranchProblem()
makeStandardReposWindow(found)
})
grid.NewButton("unknown branches", func() {
@ -113,14 +108,88 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
})
grid.NextRow()
grid.NewButton("remote devel != local devel", func() {
log.Info("not done yet")
found = develRemoteProblem()
txt = fmt.Sprintf("remote devel != local devel (%d)", found.Len())
grid.NewButton(txt, func() {
found := develRemoteProblem()
makeStandardReposWindow(found)
})
grid.NewButton("remote master != local master", func() {
log.Info("not done yet")
found = masterRemoteProblem()
txt = fmt.Sprintf("remote master != local master (%d)", found.Len())
grid.NewButton(txt, func() {
found := masterRemoteProblem()
makeStandardReposWindow(found)
})
grid.NextRow()
return pw
}
func remoteUserBranchProblem() *gitpb.Repos {
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
username := repo.GetUserBranchName()
if repo.IsBranchRemote(username) {
found.AppendByGoPath(repo)
}
}
return found
}
func develRemoteProblem() *gitpb.Repos {
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
brname := repo.GetDevelBranchName()
if !repo.IsBranchRemote(brname) {
// log.Info("repo does not have remote devel branch", repo.GetGoPath())
continue
}
lhash := repo.GetLocalHash(brname)
rhash := repo.GetRemoteHash(brname)
// log.Info(lhash, rhash, repo.GetGoPath())
if lhash == "" || rhash == "" {
// something is wrong if either of these are blank
found.AppendByGoPath(repo)
continue
}
if lhash == rhash {
continue
}
found.AppendByGoPath(repo)
}
return found
}
func masterRemoteProblem() *gitpb.Repos {
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
brname := repo.GetMasterBranchName()
if !repo.IsBranchRemote(brname) {
// log.Info("repo does not have remote devel branch", repo.GetGoPath())
continue
}
lhash := repo.GetLocalHash(brname)
rhash := repo.GetRemoteHash(brname)
// log.Info(lhash, rhash, repo.GetGoPath())
if lhash == "" || rhash == "" {
// something is wrong if either of these are blank
found.AppendByGoPath(repo)
continue
}
if lhash == rhash {
continue
}
found.AppendByGoPath(repo)
}
return found
}