deprecate old stuff

This commit is contained in:
Jeff Carr 2025-07-01 18:54:41 -05:00
parent 1d50f9eb69
commit 1ea9bdf841
9 changed files with 80 additions and 90 deletions

View File

@ -130,16 +130,16 @@ func doAllCheckoutUser() error {
log.Printf("User branch check. %d total repos. (%d ok) (%d not on user branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now)))
if err != nil {
// display all repos not on user
me.found = new(gitpb.Repos)
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
me.forge.PrintHumanTable(me.found)
log.Printf("There are %d repos that are NOT on the user branch\n", me.found.Len())
me.forge.PrintHumanTable(found)
log.Printf("There are %d repos that are NOT on the user branch\n", found.Len())
return err
}
return nil
@ -172,16 +172,16 @@ func doAllCheckoutDevel() error {
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 err != nil {
// display all repos not on user
me.found = new(gitpb.Repos)
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetCurrentBranchName() != repo.GetDevelBranchName() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
me.forge.PrintHumanTable(me.found)
log.Printf("There are %d repos that are NOT on the devel branch\n", me.found.Len())
me.forge.PrintHumanTable(found)
log.Printf("There are %d repos that are NOT on the devel branch\n", found.Len())
return err
}
return nil
@ -239,16 +239,16 @@ func doAllCheckoutMaster() error {
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 err != nil {
// display all repos not on master
me.found = new(gitpb.Repos)
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if repo.GetCurrentBranchName() != repo.GetMasterBranchName() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
me.forge.PrintHumanTable(me.found)
log.Printf("There are %d repos that are NOT on the master branch\n", me.found.Len())
me.forge.PrintHumanTable(found)
log.Printf("There are %d repos that are NOT on the master branch\n", found.Len())
return err
}
return nil

View File

@ -45,8 +45,9 @@ func doCommit() {
}
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
me.found.Append(repo)
me.forge.PrintHumanTable(me.found)
found := new(gitpb.Repos)
found.Append(repo)
me.forge.PrintHumanTable(found)
log.Info("")
log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
log.Info("")
@ -72,8 +73,9 @@ func doCommit() {
func doCommitRepo(repo *gitpb.Repo) error {
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
me.found.Append(repo)
me.forge.PrintHumanTable(me.found)
found := new(gitpb.Repos)
found.Append(repo)
me.forge.PrintHumanTable(found)
log.Info("")
log.Info("wrong branch. Can not commit on", repo.GetCurrentBranchName())
log.Info("")

View File

@ -8,7 +8,7 @@ import (
)
// this populates a slice of protobuf records representing each git repo
// var me.found []*gitpb.Repo
// var found []*gitpb.Repo
//
// so, it makes a subset of repos that are then used performing actions on
//
@ -40,8 +40,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
}
if f.Private {
findPrivate()
return me.found
return findPrivate()
}
if f.Mine {
@ -49,8 +48,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
}
if f.Favorites {
findFavorites()
return me.found
return findFavorites()
}
if f.Dirty {
@ -58,19 +56,21 @@ func (f *FindCmd) findRepos() *gitpb.Repos {
}
if f.User {
findUser()
return me.found
return findUser()
}
return findAll()
}
func findPrivate() {
func findPrivate() *gitpb.Repos {
found := gitpb.NewRepos()
for repo := range me.forge.Repos.IterByFullPath() {
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
return found
}
// finds repos that are writable
@ -88,19 +88,23 @@ func findMine() *gitpb.Repos {
}
// finds repos the user has marked as favorites in the forge .config
func findFavorites() {
func findFavorites() *gitpb.Repos {
found := gitpb.NewRepos()
// log.Printf("get favorites %s\n", me.forge.GetGoSrc())
for repo := range me.forge.Repos.IterByFullPath() {
if me.forge.Config.IsFavorite(repo.GetGoPath()) {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
return found
}
// finds repos that git is reporting as dirty
func findDirty() *gitpb.Repos {
found := gitpb.NewRepos()
for repo := range me.forge.Repos.IterByFullPath() {
if repo.IsDirty() {
found.AppendByGoPath(repo)
@ -117,33 +121,41 @@ func findAll() *gitpb.Repos {
return found
}
func findUser() {
func findUser() *gitpb.Repos {
found := gitpb.NewRepos()
for repo := range me.forge.Repos.IterByFullPath() {
if repo.GetCurrentBranchName() == repo.GetUserBranchName() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
return found
}
func findPublishable() {
func findPublishable() *gitpb.Repos {
found := gitpb.NewRepos()
for repo := range me.forge.Repos.IterByFullPath() {
if repo.GetTargetVersion() == "" {
continue
}
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
return found
}
func findReposWithPatches() *gitpb.Repos {
found := gitpb.NewRepos()
for repo := range me.forge.Repos.IterByFullPath() {
if repo.GetTargetVersion() != "" {
// add everything that has a target version set
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
continue
}
if repo.IsDirty() {
// always add dirty branches
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
continue
}
if repo.GetUserVersion() == "" || repo.GetUserVersion() == "uerr" {
@ -151,7 +163,7 @@ func findReposWithPatches() *gitpb.Repos {
continue
}
if repo.GetUserVersion() != repo.GetDevelVersion() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
continue
}
@ -160,10 +172,10 @@ func findReposWithPatches() *gitpb.Repos {
continue
}
if repo.GetLastTag() != repo.GetMasterVersion() {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
repo.FindLastTag()
continue
}
}
return me.found
return found
}

View File

@ -360,7 +360,7 @@ func findMergeToDevel() *gitpb.Repos {
for repo := range me.forge.Repos.IterByFullPath() {
// this sees if user has patches for devel. If it does, add it to me.found
// this sees if user has patches for devel. If it does, add it to found
if repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName()) > 0 {
found.AppendByGoPath(repo)
}
@ -377,8 +377,8 @@ func findMergeToDevel() *gitpb.Repos {
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)))
return found
}
func findMergeToMaster() {
me.found = new(gitpb.Repos)
func findMergeToMaster() *gitpb.Repos {
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
@ -407,30 +407,31 @@ func findMergeToMaster() {
// this sees if devel has patches for master. If it does, add it to me.found
if repo.CountDiffObjects(repo.GetDevelBranchName(), repo.GetMasterBranchName()) > 0 {
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
}
now := time.Now()
if me.found.Len() == 0 {
if found.Len() == 0 {
log.Info("nothing to merge with master")
return
return found
}
me.forge.PrintHumanTable(me.found)
me.forge.PrintHumanTable(found)
// check for merges from devel
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)))
return found
}
func mergeDevelToMaster(doit bool) {
findMergeToMaster()
found := findMergeToMaster()
if !doit {
return
}
all := me.found.SortByFullPath()
all := found.SortByFullPath()
for all.Scan() {
repo := all.Next()
log.Info("repo:", repo.GetGoPath())

View File

@ -31,12 +31,12 @@ func doPatch() error {
// if no option is given to patch, list out the
// repos that have patches ready in them
findReposWithPatches()
if me.found.Len() == 0 {
found := findReposWithPatches()
if found.Len() == 0 {
log.Info("you currently have no patches in your user branches")
return nil
}
me.forge.PrintHumanTable(me.found)
me.forge.PrintHumanTable(found)
return nil
}

View File

@ -72,7 +72,6 @@ func main() {
// load the ~/.config/forge/ config
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
// first find the repos or gopaths to operate on
if argv.Config != nil {
@ -179,7 +178,8 @@ func main() {
// nothing else was specified to be done,
// then just list the table to stdout
if gui.NoGui() {
me.forge.PrintHumanTable(me.found)
found := doFind()
me.forge.PrintHumanTable(found)
okExit("")
}

View File

@ -8,7 +8,6 @@ import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
)
var me *mainType
@ -26,40 +25,18 @@ type mainType struct {
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
forge *forgepb.Forge // for holding the forge protobuf files
myGui *gui.Node // the gui toolkit handle
found *gitpb.Repos // stores the list of repos to process things on
psets *forgepb.Patchsets // the locally stored on disk patchsets
foundPaths []string // stores gopaths to act on (when doing go-clone)
configSave bool // if the config file should be saved after finishing
urlbase string // base URL
// our view of the repositories
// patchWin *patchesWindow
mainWindow *gadgets.BasicWindow
mainbox *gui.Node // the main box. enable/disable this
autoDryRun *gui.Node // checkbox for --dry-run
goSrcPwd *gadgets.OneLiner // what is being used as primary directory for your work
gitAuthor *gadgets.OneLiner // ENV GIT_AUTHOR NAME and EMAIL
// the main box. enable/disable this
mainbox *gui.Node
// the window from the /lib/gui/gowit package
// lw *gadgets.BasicWindow
// #### Sorting options for the repolist
// autoHidePerfect *gui.Node
// autoHideReadOnly *gui.Node
// checkbox for --dry-run
autoDryRun *gui.Node
// checkbox to enable intermittent scanning
// if checked, it will check all your repos for changes
autoScanReposCB *gui.Node
goSrcPwd *gadgets.OneLiner // what is being used as primary directory for your work
gitAuthor *gadgets.OneLiner // ENV GIT_AUTHOR NAME and EMAIL
forgeMode *gui.Node // is the user in 'master', 'devel' or 'user' branches
// these hold the branches that the user can switch all
// the repositories to them
// these hold the branches that the user can switch all the repositories to them
newBranch *gui.Node // deprecate?
setBranchB *gui.Node // deprecate?
reposWinB *gui.Node // button that opens the repos window
@ -67,11 +44,10 @@ type mainType struct {
repoDirtyB *gui.Node // "dirty" repos button
repoDevelMergeB *gui.Node // "merge to devel" repos button
repoWritableB *gui.Node // "what repos are writable" repos button
// modeReleaseW *gui.Node // opens the release window
// modePatchW *gui.Node // opens the patch window
// modeUserW *gui.Node // opens the user/hack window
argvCheckoutUser bool // shared between the GUI and the command line tools
argvCheckoutDevel bool // shared between the GUI and the command line tools
argvCheckoutMaster bool // shared between the GUI and the command line tools
// deprecate these
forgeMode *gui.Node // is the user in 'master', 'devel' or 'user' branches
argvCheckoutUser bool // shared between the GUI and the command line tools
argvCheckoutDevel bool // shared between the GUI and the command line tools
argvCheckoutMaster bool // shared between the GUI and the command line tools
}

View File

@ -24,7 +24,7 @@ type foundWindow struct {
dirtyOL *gadgets.OneLiner
readonlyOL *gadgets.OneLiner
rw *gadgets.OneLiner
// checkB *gui.Node
found *gitpb.Repos
}
func (r *foundWindow) Hidden() bool {
@ -79,7 +79,7 @@ func (r *foundWindow) initWindow() {
}
func (r *foundWindow) listRepos() {
for repo := range me.found.IterAll() {
for repo := range r.found.IterAll() {
r.addRepo(repo)
}
}

View File

@ -69,12 +69,11 @@ func makeReposWinNew() *gadgets.GenericWindow {
t.Delete()
t = nil
}
me.found = new(gitpb.Repos)
findReposWithPatches()
me.forge.PrintHumanTable(me.found)
found := findReposWithPatches()
me.forge.PrintHumanTable(found)
// make the window for the first time
t = addWindowPB(insertWin, me.found)
t = addWindowPB(insertWin, found)
f := func(repo *gitpb.Repo) {
log.Info("got to ReposTable.Custom() id =", repo.GetGoPath(), repo.GetCurrentVersion())
}