summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go7
-rw-r--r--doExamine.go279
-rw-r--r--main.go6
-rw-r--r--windowRepos.go203
4 files changed, 0 insertions, 495 deletions
diff --git a/argv.go b/argv.go
index ae920f5..20cc4f9 100644
--- a/argv.go
+++ b/argv.go
@@ -40,16 +40,9 @@ type EmptyCmd struct {
type testCmd string
-type ExamineCmd struct {
- Fix *EmptyCmd `arg:"subcommand:fix" help:"try to auto fix branches"`
- Show *EmptyCmd `arg:"subcommand:show" help:"show a specific patch"`
- Submit string `arg:"--submit" help:"name of patchset"`
-}
-
type CleanCmd struct {
Delete *EmptyCmd `arg:"subcommand:delete" help:"rescan repo"`
Devel *CleanDevelCmd `arg:"subcommand:devel" help:"clean and verify the devel branches"`
- Examine *ExamineCmd `arg:"subcommand:examine" help:"examine branches"`
Force *EmptyCmd `arg:"subcommand:force" help:"do destructive stuff"`
GitReset *EmptyCmd `arg:"subcommand:git-reset" help:"git reset --hard"`
Pub *EmptyCmd `arg:"subcommand:pub" help:"clean target version numbers"`
diff --git a/doExamine.go b/doExamine.go
deleted file mode 100644
index 45d0705..0000000
--- a/doExamine.go
+++ /dev/null
@@ -1,279 +0,0 @@
-// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
-// Use of this source code is governed by the GPL 3.0
-
-package main
-
-import (
- "fmt"
- "path/filepath"
- "slices"
- "time"
-
- "go.wit.com/lib/gui/shell"
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
-func doExamine() error {
- me.found = new(gitpb.Repos)
- all := me.forge.Repos.SortByFullPath()
- for all.Scan() {
- repo := all.Next()
- if tag := repo.ExamineBranches(); tag != nil {
- me.found.AppendByGoPath(repo)
- // ctime := tag.Creatordate.AsTime()
- // dur := time.Since(ctime)
- // log.Printf("UNKNOWN BRANCH %-50s %s %4s %s\n", repo.GetFullPath(), tag.Hash, shell.FormatDuration(dur), tag.Refname)
- repo.CurrentTag = tag
- } else {
- repo.CurrentTag = nil
- }
- }
- if len(me.found.Repos) == 0 {
- return nil
- }
- // slices.Reverse(me.found.Repos)
- slices.SortFunc(me.found.Repos, func(a, b *gitpb.Repo) int {
- atime := a.CurrentTag.Creatordate.AsTime()
- btime := b.CurrentTag.Creatordate.AsTime()
- if atime.Before(btime) {
- // log.Info("atime vs btime is 0", atime, btime)
- return 1
- }
- // log.Info("atime vs btime is 1", atime, btime)
- return -1
- })
- all = me.found.All()
- me.found = new(gitpb.Repos)
- for all.Scan() {
- repo := all.Next()
- if isNormal(repo) {
- continue
- }
-
- tag := repo.CurrentTag
- ctime := tag.Creatordate.AsTime()
- dur := time.Since(ctime)
- log.Printf("UNKNOWN BRANCH %-50s %s %4s %s\n", repo.GetFullPath(), tag.Hash, shell.FormatDuration(dur), tag.Refname)
- err := examineBranch(repo)
- if argv.Clean.Examine.Fix != nil {
- if err != nil {
- badExit(err)
- }
- }
-
- me.found.AppendByGoPath(repo)
- }
- me.forge.PrintHumanTableDirty(me.found)
- return nil
-}
-
-func isNormal(repo *gitpb.Repo) bool {
- if repo.IsDirty() {
- return true
- }
- if repo.GetUserVersion() != repo.GetDevelVersion() {
- return true
- }
- return false
-}
-
-func examineBranch(repo *gitpb.Repo) error {
- if !isLocal(repo) {
- base := filepath.Base(repo.CurrentTag.Refname)
- if base == repo.GetUserBranchName() {
- log.Info("The user branch also has a remote branch", repo.CurrentTag.Refname)
- log.Info("TODO: verify the remote branch is out of date", repo.CurrentTag.Refname)
- log.Info("TODO: delete the remote branch", repo.CurrentTag.Refname)
- return nil
- }
-
- if repo.Exists(filepath.Join(".git/refs/heads", base)) {
- repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
- repo.RunVerbose([]string{"cat", filepath.Join(".git/refs/remotes/origin", base)})
- repo.RunVerbose([]string{"cat", filepath.Join(".git/refs/heads", base)})
- log.Info("why is this local branch a problem?", repo.CurrentTag.Refname)
- } else {
- repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
- log.Info("why is this non-local branch a problem?", repo.CurrentTag.Refname)
- r, err := repo.RunStrict([]string{"cat", filepath.Join(".git/refs/remotes/origin", base)})
- if err == nil {
- cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]}
- repo.RunVerbose(cmd)
- log.Info(cmd)
- return nil
- }
- }
- return fmt.Errorf("%s repo.CurrentTag is not local: %s. Don't proceed yet", repo.GetGoPath(), repo.CurrentTag.Refname)
- }
- dcount, err := showNotMaster(repo)
- if err != nil {
- return err
- }
- if repo.CurrentTag == nil {
- return fmt.Errorf("repo.CurrentTag == nil")
- }
-
- userbranch := repo.GetUserBranchName()
-
- if repo.CurrentTag.Refname == userbranch {
- return requiresGitPush(repo, userbranch)
- }
-
- if repo.CurrentTag.Refname == "origin/"+userbranch {
- return requiresGitPush(repo, userbranch)
- }
-
- if len(dcount) == 0 {
- if repo.CurrentTag.Refname == repo.GetMasterBranchName() {
- err = fmt.Errorf("examineBranch() SPECIAL CASE. %s is the master branch", repo.CurrentTag.Refname)
- log.Info(err)
- return nil
- }
-
- err = fmt.Errorf("examineBranch() branch differs. patch diff len == 0. PROBABLY DELETE BRANCH %s", repo.CurrentTag.Refname)
- log.Info(err)
- cmd := repo.ConstructGitDiffLog(repo.CurrentTag.Refname, repo.GetMasterBranchName())
- if argv.Clean.Examine.Fix == nil {
- log.Info(repo.GetGoPath(), cmd)
- } else {
- if err := repo.RunVerbose(cmd); err != nil {
- return err
- }
- }
- cmd = repo.ConstructGitDiffLog(repo.GetMasterBranchName(), repo.CurrentTag.Refname)
- if argv.Clean.Examine.Fix == nil {
- log.Info(repo.GetGoPath(), cmd)
- } else {
- if err := repo.RunVerbose(cmd); err != nil {
- return err
- }
- }
- cmd = []string{"git", "branch", "-D", repo.CurrentTag.Refname}
- log.Info(repo.GetGoPath(), "TRY THIS:", cmd)
- if argv.Clean.Examine.Fix == nil {
- log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
- repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
- } else {
- log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
- if err := repo.RunVerbose(cmd); err != nil {
- return err
- } else {
- return nil
- }
- }
- return err
- }
- err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount))
- log.Info(err)
- return nil
-}
-
-func checkJcarr(repo *gitpb.Repo) int {
- b1 := countDiffObjects(repo, "jcarr", "origin/jcarr")
- b2 := countDiffObjects(repo, "origin/jcarr", "jcarr")
- log.Info("jcarr vs origin count", b1, b2)
- if b1 == 0 && b2 == 0 {
- return 0
- }
- if b1 != 0 {
- log.Info("jcarr vs origin count b1 != 0, b2 ==", b1, b2)
- log.Info("THIS MEANS THE LOCAL BRANCH NEEDS GIT PUSH TO ORIGIN BRANCH ==", b1, b2)
- return b1
- }
- if b2 != 0 {
- log.Info("jcarr vs origin count b2 != 0, b1 ==", b2, b1)
- return b2
- }
- return -1
-}
-
-func isLocal(repo *gitpb.Repo) bool {
- base, name := filepath.Split(repo.CurrentTag.Refname)
- if name == "" {
- return false
- }
- if base == "" {
- return true
- }
- return false
-}
-
-func showNotMaster(repo *gitpb.Repo) ([]string, error) {
- var cmd []string
- cmd = append(cmd, "git")
- cmd = append(cmd, "log")
- cmd = append(cmd, "--format=\"%H\"")
- cmd = append(cmd, repo.CurrentTag.Hash)
- cmd = append(cmd, "--not")
- cmd = append(cmd, repo.GetMasterBranchName())
- r, err := repo.RunStrict(cmd)
- return r.Stdout, err
-}
-
-func showNotDevel(repo *gitpb.Repo) ([]string, error) {
- var cmd []string
- cmd = append(cmd, "git")
- cmd = append(cmd, "log")
- cmd = append(cmd, "--format=\"%H\"")
- cmd = append(cmd, repo.CurrentTag.Hash)
- cmd = append(cmd, "--not")
- cmd = append(cmd, "devel")
- r, err := repo.RunStrict(cmd)
- return r.Stdout, err
-}
-
-// count all objects only in branch1
-func countDiffObjects(repo *gitpb.Repo, branch1, branch2 string) int {
- cmd := repo.ConstructGitDiffLog(branch1, branch2)
- r, err := repo.RunStrict(cmd)
- if err != nil {
- return -1
- }
- // log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " "))
- return len(r.Stdout)
-}
-
-/*
-func constructGitDiffLog(repo *gitpb.Repo, branch1, branch2 string) []string {
- var cmd []string
- cmd = append(cmd, "git")
- cmd = append(cmd, "log")
- cmd = append(cmd, "--format=\"%H\"")
- cmd = append(cmd, branch1)
- cmd = append(cmd, "--not")
- cmd = append(cmd, branch2)
- return cmd
-}
-*/
-
-// count all objects only in branch1
-func gitPushStrict(repo *gitpb.Repo, branchName string) error {
- var cmd []string
- cmd = append(cmd, "git")
- cmd = append(cmd, "push")
- err := repo.RunVerbose(cmd)
- if err != nil {
- cmd = []string{"git", "whatchanged", repo.CurrentTag.Hash, "-1"}
- repo.RunVerbose(cmd)
- }
- return err
-}
-
-func requiresGitPush(repo *gitpb.Repo, branchName string) error {
- b1 := countDiffObjects(repo, branchName, "origin/"+branchName)
- b2 := countDiffObjects(repo, "origin/"+branchName, branchName)
- log.Info(branchName, "vs origin count", b1, b2)
- if b1 == 0 && b2 == 0 {
- return nil
- }
- if b1 != 0 {
- log.Info(branchName, "vs origin count b1 != 0, b2 ==", b1, b2)
- log.Info("THIS MEANS THE LOCAL BRANCH NEEDS GIT PUSH TO ORIGIN BRANCH ==", b1)
- if argv.Clean.Examine.Fix != nil {
- return gitPushStrict(repo, branchName)
- }
- return nil
- }
- return nil
-}
diff --git a/main.go b/main.go
index b9d4004..e558cc0 100644
--- a/main.go
+++ b/main.go
@@ -104,12 +104,6 @@ func main() {
log.Info("only looking at repo:", argv.Clean.Repo)
okExit("")
}
- if argv.Clean.Examine != nil {
- if err := doExamine(); err != nil {
- badExit(err)
- }
- okExit("")
- }
if argv.Clean.GitReset != nil {
findAll() // select all the repos
diff --git a/windowRepos.go b/windowRepos.go
index bc34318..a7a3018 100644
--- a/windowRepos.go
+++ b/windowRepos.go
@@ -5,8 +5,6 @@ package main
import (
"go.wit.com/lib/gadgets"
- "go.wit.com/lib/gui/repolist"
- "go.wit.com/log"
"go.wit.com/gui"
)
@@ -15,9 +13,6 @@ type repoWindow struct {
win *gadgets.BasicWindow // the window widget itself
box *gui.Node // notsure
topbox *gui.Node // the top box of the repolist window
- // mergeDevel *gui.Node // the buttton for merging user into devel
- // mergeMaster *gui.Node // the buttton for merging devel into master
- View *repolist.RepoList // old code
}
func (r *repoWindow) Hidden() bool {
@@ -38,40 +33,6 @@ func (r *repoWindow) Show() {
return
}
r.win.Show()
-
- /*
- now := time.Now()
- // check for devel branches
- total, count, nope, _ := IsEverythingOnDevel()
- log.Printf("Devel branch check. %d total repos. (%d ok) (%d not on devel branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now)))
- if nope != 0 {
- // r.mergeDevel.Disable()
- } else {
- // everything is on the devel branch
- // r.mergeDevel.Enable()
- }
-
- // check for master branches
- total, count, nope, _ = IsEverythingOnMaster()
- log.Printf("Master branch check. %d total repos. (%d ok) (%d not on master branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now)))
- if nope != 0 {
- r.mergeMaster.Disable()
- } else {
- // everything is on the master branch
- r.mergeMaster.Enable()
- }
- */
-
- // updates the rows not hidden
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- if view.Hidden() {
- continue
- }
- view.Update()
- }
}
func (r *repoWindow) Hide() {
@@ -103,167 +64,3 @@ func (r *repoWindow) Enable() {
}
r.box.Enable()
}
-
-func (r *repoWindow) repoMenu() *gui.Node {
- // reposbox.SetExpand(false)
- group1 := r.box.NewGroup("Filter:")
-
- hbox := group1.Box()
- // hbox.Horizontal()
- hbox.Vertical()
-
- box2 := hbox.Box().Horizontal()
-
- all := box2.NewCheckbox("all")
- all.Custom = func() {
- log.Info("filter all =", all.Checked())
- if all.Checked() {
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- view.Show()
- }
- } else {
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- view.Hide()
- }
- }
- }
-
- dirty := box2.NewCheckbox("dirty")
- dirty.Custom = func() {
- log.Info("filter dirty =", dirty.Checked())
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- if view.Hidden() {
- view.Show()
- }
- }
- }
-
- /*
- r.mergeDevel = box2.NewButton("merge to devel", func() {
- r.Disable()
- defer r.Enable()
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- if view.Hidden() {
- continue
- }
- repo := view.GetPb()
- log.Info("repo:", repo.GetGoPath())
- if result, err := repo.MergeToDevel(); err == nil {
- log.Warn("THINGS SEEM OK", repo.GetFullPath())
- for _, line := range result.Stdout {
- log.Warn("stdout:", line)
- }
- for _, line := range result.Stderr {
- log.Warn("stderr:", line)
- }
- } else {
- log.Warn("THINGS FAILED ", repo.GetFullPath())
- log.Warn("err", err)
- if result == nil {
- break
- }
- for _, line := range result.Stdout {
- log.Warn("stdout:", line)
- }
- for _, line := range result.Stderr {
- log.Warn("stderr:", line)
- }
- break
- }
- me.forge.SetConfigSave(true)
- view.Update()
- }
- me.forge.ConfigSave()
- })
-
- r.mergeMaster = box2.NewButton("merge to master", func() {
- r.Disable()
- defer r.Enable()
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- if view.Hidden() {
- continue
- }
- repo := view.GetPb()
- log.Info("repo:", repo.GetGoPath())
- if result, err := repo.MergeToMaster(); err == nil {
- log.Warn("THINGS SEEM OK", repo.GetFullPath())
- for _, line := range result.Stdout {
- log.Warn("stdout:", line)
- }
- for _, line := range result.Stderr {
- log.Warn("stderr:", line)
- }
- } else {
- log.Warn("THINGS FAILED ", repo.GetFullPath())
- if result == nil {
- break
- }
- log.Warn("err", err)
- for _, line := range result.Stdout {
- log.Warn("stdout:", line)
- }
- for _, line := range result.Stderr {
- log.Warn("stderr:", line)
- }
- break
- }
- me.forge.SetConfigSave(true)
- view.Update()
- }
- me.forge.ConfigSave()
- })
- */
- box2.NewButton("update", func() {
- r.Disable()
- defer r.Enable()
- loop := r.View.ReposSortByName()
- for loop.Scan() {
- // var repo *repolist.RepoRow
- view := loop.Repo()
- if view.Hidden() {
- continue
- }
- repo := view.GetPb()
- // log.Info("check master vs devel here on", repo.GetGoPath())
- if repo.GetDevelVersion() == repo.GetMasterVersion() {
- continue
- }
- b1 := countDiffObjects(repo, repo.GetMasterBranchName(), repo.GetDevelBranchName())
- if b1 == 0 {
- // log.Info("master vs devel count is normal b1 == 0", b1)
- } else {
- // log.Info("master vs devel count b1 != 0", b1)
- log.Info("SERIOUS ERROR. DEVEL BRANCH NEEDS MERGE FROM MASTER b1 ==", b1, repo.GetGoPath())
- }
- /*
- // THIS IS TERRIBLE. STOP DEVELOPING AND FIX THIS IF THIS HAPPENS
- cmd := repo.ConstructGitDiffLog(repo.GetMasterBranchName(), repo.GetDevelBranchName())
- if _, err := repo.RunVerbose(cmd); err != nil {
- log.Info("failed", err)
- }
- */
- /* this is normal
- cmd := repo.ConstructGitDiffLog(repo.GetDevelBranchName(), repo.GetMasterBranchName())
- if _, err := repo.RunVerbose(cmd); err != nil {
- log.Info("failed", err)
- }
- */
- }
- })
- return box2
-}