diff options
Diffstat (limited to 'windowRepoProblems.go')
| -rw-r--r-- | windowRepoProblems.go | 103 |
1 files changed, 86 insertions, 17 deletions
diff --git a/windowRepoProblems.go b/windowRepoProblems.go index 4ff6be4..9b22bb1 100644 --- a/windowRepoProblems.go +++ b/windowRepoProblems.go @@ -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 +} |
