From f53f1256f184c0cddb565eebb7ecb2f8f1e079d3 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 7 Jan 2025 19:29:46 -0600 Subject: [PATCH] more rm old code --- common.go | 57 +++++++++++++ goConfig.go | 28 ------- ideas/pruneTags.go | 32 ++++++++ revert.go => ideas/revert.go | 0 timer.go => ideas/timer.go | 17 ++++ merge.go | 154 ----------------------------------- mirror.go | 42 ---------- update.go | 95 +-------------------- 8 files changed, 107 insertions(+), 318 deletions(-) delete mode 100644 goConfig.go create mode 100644 ideas/pruneTags.go rename revert.go => ideas/revert.go (100%) rename timer.go => ideas/timer.go (54%) delete mode 100644 merge.go delete mode 100644 mirror.go diff --git a/common.go b/common.go index 08a7625..2d30b93 100644 --- a/common.go +++ b/common.go @@ -62,3 +62,60 @@ func (rs *RepoStatus) Ready() bool { } return rs.ready } + +// disable all things besides Update() button +func (rs *RepoStatus) DisableEverything() { + log.Log(INFO, "DisableEverything()") + + // choosing a major, minor or revision + rs.major.Disable() + rs.minor.Disable() + rs.revision.Disable() + + // disable adding a tag message + rs.versionMessage.Disable() + + // disable the merge devel to master button + rs.develMergeB.Disable() + + // disable the tag a new version button + rs.releaseVersion.Disable() +} + +// this means devel needs to be merged to master +func (rs *RepoStatus) EnableMergeDevel() { + rs.DisableEverything() + + rs.develMergeB.Enable() +} + +func (rs *RepoStatus) Disable() { + rs.window.Disable() +} + +func (rs *RepoStatus) Enable() { + rs.window.Enable() +} + +// this means you need to release a new version of the master repository +func (rs *RepoStatus) EnableSelectTag() { + rs.DisableEverything() + + // choosing a major, minor or revision + rs.major.Enable() + rs.minor.Enable() + rs.revision.Enable() + + // disable adding a tag message + rs.versionMessage.Enable() + + rs.develMergeB.SetLabel("ready to release") + + if len(rs.versionMessage.String()) == 0 { + // force there to be a commit message + rs.releaseVersion.Disable() + } else { + // rs.generateCmd() + rs.releaseVersion.Enable() + } +} diff --git a/goConfig.go b/goConfig.go deleted file mode 100644 index d68bcb7..0000000 --- a/goConfig.go +++ /dev/null @@ -1,28 +0,0 @@ -package repostatus - -// does processing on the go.mod and go.sum files - -/* -// for now, even check cmd.Exit -func (rs *RepoStatus) strictRun(cmd []string) (bool, error) { - r := rs.Run(cmd) - if r.Error != nil { - log.Log(REPO, "go mod init failed err:", r.Error) - return false, r.Error - } - if r.Exit != 0 { - log.Log(REPO, "go mod init exit =", r.Exit) - return false, r.Error - } - return true, nil -} -*/ - -/* -func (rs *RepoStatus) IsReleased() bool { - if rs.GetTargetVersion() == rs.GetCurrentVersion() { - return true - } - return false -} -*/ diff --git a/ideas/pruneTags.go b/ideas/pruneTags.go new file mode 100644 index 0000000..85a2990 --- /dev/null +++ b/ideas/pruneTags.go @@ -0,0 +1,32 @@ +package repostatus + +import ( + "strings" + + "go.wit.com/log" +) + +func (rs *RepoStatus) setGitCommands() { + var line1, line2, line3 []string + var all [][]string + + newTag := rs.newversion.String() + line1 = append(line1, "git", "tag", "v"+newTag, "-m", rs.versionMessage.String()) + all = append(all, line1) + line2 = append(line2, "git", "push", "--tags") + all = append(all, line2) + line3 = append(line3, "git", "push", "--prune", "--tags") + all = append(all, line3) + + rs.versionCmds = all + + var tmp []string + // convert to displayable to the user text + for _, line := range all { + s := strings.Join(line, " ") + log.Log(INFO, "s =", s) + tmp = append(tmp, s) + } + + rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n")) +} diff --git a/revert.go b/ideas/revert.go similarity index 100% rename from revert.go rename to ideas/revert.go diff --git a/timer.go b/ideas/timer.go similarity index 54% rename from timer.go rename to ideas/timer.go index 067a85a..3d18445 100644 --- a/timer.go +++ b/ideas/timer.go @@ -17,3 +17,20 @@ func (ls *RepoStatus) SetSpeedActual(s string) { } ls.speedActual.SetValue(s) } + +func (rs *RepoStatus) setSpeed(duration time.Duration) { + s := fmt.Sprint(duration) + if rs.speedActual == nil { + log.Log(WARN, "rs.speedActual == nil") + return + } + rs.speedActual.SetValue(s) + + if duration > 200*time.Millisecond { + rs.speed.SetValue("SLOW") + } else if duration > 50*time.Millisecond { + rs.speed.SetValue("OK") + } else { + rs.speed.SetValue("FAST") + } +} diff --git a/merge.go b/merge.go deleted file mode 100644 index 0dea6f2..0000000 --- a/merge.go +++ /dev/null @@ -1,154 +0,0 @@ -package repostatus - -import ( - "strings" - - "go.wit.com/log" -) - -/* -func (rs *RepoStatus) recommend() { - log.Log(INFO, "Is repo dirty?", rs.dirtyLabel.String()) - log.Log(INFO, "list the known tags") - rs.DisableEverything() - rs.populateTags() - log.Log(INFO, "Does devel == user?", rs.develBranchVersion.String(), rs.userBranchVersion.String()) - if rs.develBranchVersion.String() != rs.userBranchVersion.String() { - log.Log(INFO, "devel does not equal user") - log.Log(INFO, "merge or squash?") - rs.EnableMergeDevel() - rs.setMergeUserCommands() - label := "merge user into " + rs.GetDevelBranchName() - rs.develMergeB.SetLabel(label) - return - } - log.Log(INFO, "Does master == devel? ", rs.GetMasterVersion(), rs.GetDevelVersion()) - if rs.GetMasterVersion() != rs.GetDevelVersion() { - log.Log(INFO, "master does not equal devel. merge devel into master") - rs.EnableMergeDevel() - rs.setMergeDevelCommands() - label := "merge devel into " + rs.GetMasterBranchName() - rs.develMergeB.SetLabel(label) - return - } - if rs.lasttag.String() != rs.GetMasterVersion() { - log.Log(INFO, "master does not equal last tag") - rs.incrementRevision() - rs.EnableSelectTag() - rs.setTag() - return - } - log.Log(INFO, "Is repo pushed upstream? git.wit.org or github?") -} -*/ - -/* -func (rs *RepoStatus) generateCmd() bool { - // the length of 24 is arbitrary, but should be short - // they should be things like perhaps, major release names - // or something the users might see. - // aka: "Topsy", "Picasso", "Buzz", etc - - if !rs.setTag() { - log.Log(INFO, "tag sucked. fix your tag version") - rs.versionMessage.SetLabel("tag message (bad version)") - rs.releaseVersion.Disable() - return false - } - - log.Log(INFO, "tag is valid!!!!") - rs.setGitCommands() - - if rs.versionMessage.String() == "" { - log.Log(INFO, "tag message is empty!!!!") - rs.releaseVersion.Disable() - return false - } - if len(rs.versionMessage.String()) > 24 { - rs.versionMessage.SetLabel("tag message (too long)") - } else { - rs.versionMessage.SetLabel("tag message") - } - rs.releaseVersion.SetLabel("Release Tag!") - rs.releaseVersion.Enable() - return true -} -*/ - -/* -func (rs *RepoStatus) runGitCommands(verbose bool) bool { - var line []string - for _, line = range rs.versionCmds { - s := strings.Join(line, " ") - if verbose { - log.Log(WARN, "RUNNING:", s) - } - rs.develMergeB.SetText(s) - r := rs.Run(line) - output := strings.TrimSpace(strings.Join(r.Stdout, "\n")) - if r.Error != nil { - log.Warn("ABEND EXECUTION") - log.Warn("error =", r.Error) - log.Warn("output =", output) - return false - } - if r.Exit != 0 { - log.Warn("Returned with exit =", r.Exit) - log.Warn("output was =", output) - } - log.Log(INFO, "RUN DONE") - } - return true -} -*/ - -func (rs *RepoStatus) setGitCommands() { - var line1, line2, line3 []string - var all [][]string - - newTag := rs.newversion.String() - line1 = append(line1, "git", "tag", "v"+newTag, "-m", rs.versionMessage.String()) - all = append(all, line1) - line2 = append(line2, "git", "push", "--tags") - all = append(all, line2) - line3 = append(line3, "git", "push", "--prune", "--tags") - all = append(all, line3) - - rs.versionCmds = all - - var tmp []string - // convert to displayable to the user text - for _, line := range all { - s := strings.Join(line, " ") - log.Log(INFO, "s =", s) - tmp = append(tmp, s) - } - - rs.versionCmdOutput.SetValue(strings.Join(tmp, "\n")) -} - -/* -func (rs *RepoStatus) IsCorrectMode(mode string) bool { - switch mode { - case "master": - if rs.GetCurrentBranchName() == rs.GetMasterBranchName() { - return true - } else { - return false - } - case "devel": - if rs.GetCurrentBranchName() == rs.GetDevelBranchName() { - return true - } else { - return false - } - case "user": - if rs.GetCurrentBranchName() == rs.GetUserBranchName() { - return true - } else { - return false - } - } - return false -} -*/ diff --git a/mirror.go b/mirror.go deleted file mode 100644 index e81c71c..0000000 --- a/mirror.go +++ /dev/null @@ -1,42 +0,0 @@ -package repostatus - -import ( - "go.wit.com/gui" - // "go.wit.com/gui/gui" -) - -// this is experiemental work on making 'View's or Table Row's -// this may or may not be a good idea - -// returns a widget of the last tag that acts as a mirror -func (rs *RepoStatus) MirrorLastTag() *gui.Node { - return rs.lasttag.MirrorValue() -} - -func (rs *RepoStatus) MirrorTargetVersion() *gui.Node { - return rs.targetReleaseVersion.MirrorValue() -} - -func (rs *RepoStatus) MirrorCurrentVersion() *gui.Node { - return rs.currentVersion.MirrorValue() -} - -func (rs *RepoStatus) MirrorCurrentName() *gui.Node { - return rs.currentBranch.MirrorValue() -} - -func (rs *RepoStatus) MirrorGitState() *gui.Node { - return rs.gitState.MirrorValue() -} - -func (rs *RepoStatus) MirrorMasterVersion() *gui.Node { - return rs.mainBranchVersion.MirrorValue() -} - -func (rs *RepoStatus) MirrorDevelVersion() *gui.Node { - return rs.develBranchVersion.MirrorValue() -} - -func (rs *RepoStatus) MirrorUserVersion() *gui.Node { - return rs.userBranchVersion.MirrorValue() -} diff --git a/update.go b/update.go index 3b0c9d8..55d529f 100644 --- a/update.go +++ b/update.go @@ -2,26 +2,10 @@ package repostatus import ( "errors" - "fmt" - "time" "go.wit.com/log" ) -/* -func (rs *RepoStatus) gitBranchAll() { - r := rs.Run([]string{"git", "branch", "--all"}) - if r.Error != nil { - log.Log(WARN, "git branch failed string =", rs.Path()) - log.Log(WARN, "git branch failed realpath =", rs.realPath.String()) - return - } - for _, s := range r.Stdout { - rs.targetBranch.AddText(s) - } -} -*/ - func (rs *RepoStatus) UpdateNew() { log.Info("gui update", rs.pb.GetFullPath()) rs.updateNew() @@ -68,83 +52,6 @@ func (rs *RepoStatus) Update() { return } log.Log(INFO, "Update() START") - duration := timeFunction(func() { - rs.updateNew() - }) - rs.setSpeed(duration) + rs.updateNew() log.Log(INFO, "Update() END") } - -func (rs *RepoStatus) setSpeed(duration time.Duration) { - s := fmt.Sprint(duration) - if rs.speedActual == nil { - log.Log(WARN, "rs.speedActual == nil") - return - } - rs.speedActual.SetValue(s) - - if duration > 200*time.Millisecond { - rs.speed.SetValue("SLOW") - } else if duration > 50*time.Millisecond { - rs.speed.SetValue("OK") - } else { - rs.speed.SetValue("FAST") - } -} - -// disable all things besides Update() button -func (rs *RepoStatus) DisableEverything() { - log.Log(INFO, "DisableEverything()") - - // choosing a major, minor or revision - rs.major.Disable() - rs.minor.Disable() - rs.revision.Disable() - - // disable adding a tag message - rs.versionMessage.Disable() - - // disable the merge devel to master button - rs.develMergeB.Disable() - - // disable the tag a new version button - rs.releaseVersion.Disable() -} - -// this means devel needs to be merged to master -func (rs *RepoStatus) EnableMergeDevel() { - rs.DisableEverything() - - rs.develMergeB.Enable() -} - -func (rs *RepoStatus) Disable() { - rs.window.Disable() -} - -func (rs *RepoStatus) Enable() { - rs.window.Enable() -} - -// this means you need to release a new version of the master repository -func (rs *RepoStatus) EnableSelectTag() { - rs.DisableEverything() - - // choosing a major, minor or revision - rs.major.Enable() - rs.minor.Enable() - rs.revision.Enable() - - // disable adding a tag message - rs.versionMessage.Enable() - - rs.develMergeB.SetLabel("ready to release") - - if len(rs.versionMessage.String()) == 0 { - // force there to be a commit message - rs.releaseVersion.Disable() - } else { - // rs.generateCmd() - rs.releaseVersion.Enable() - } -}