From b805fe15c942dc4f5e84821f27978f43c333e1a4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 22 Feb 2024 11:35:23 -0600 Subject: [PATCH] auto-version and release only changed repos --- globalDisplayOptions.go | 8 +++++ main.go | 37 ----------------------- repoview.go | 2 +- setTargetVersion.go | 67 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 setTargetVersion.go diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index 94f4332..7c83a6c 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -119,7 +119,15 @@ func globalDisplayOptions(box *gui.Node) { me.setBranchesToMasterB.Disable() } }) + grid.NextRow() + var setTarget *gui.Node + // check to see if target versions need to be changed + setTarget = grid.NewButton("increment target versions", func() { + if incrementTargetVersion() { + setTarget.SetText("DONE") + } + }) grid.NextRow() group2 := vbox.NewGroup("Debugger") diff --git a/main.go b/main.go index 311f2e3..1ab0032 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "embed" "os" "path/filepath" - "strings" "go.wit.com/gui" "go.wit.com/lib/gui/shell" @@ -149,39 +148,3 @@ func setAllBranchesToMaster() bool { } return worked } - -func setTargetVersion() { - // go through and set the target versions for each repo - // todo: add sanity checking in repolist to verify these and/or autocompute them - // for now, just don't be stupid when you set your ENV vars - // widget I versioned early before I knew what the hell this would mean and can - // not be down versioned because that's not how GO versioning works. Once you - // set the version for a path, it's set in stone forever. (smart system!) - // we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning - // system, but that's rediculous and this servers to always remind me to never make this mistake again - var count int - for i, repo := range me.repos.View.AllRepos() { - if repo == nil { - log.Info("initial scan repo = nil", i) - continue - } - - if repo.Status == nil { - log.Info("repo.status == nil", repo.Name()) - continue - } - - if repo.GoPath() == "go.wit.com/widget" { - repo.Status.SetTargetVersion("v" + widgetVersion) - } else { - repo.Status.SetTargetVersion("v" + releaseVersion) - } - if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/") { - lasttag := repo.Status.GetLastTagVersion() - repo.Status.SetTargetVersion(lasttag) - } - // repo.NewScan() - count += 1 - } - log.Info("target versions set for", count, "repos") -} diff --git a/repoview.go b/repoview.go index 95dc288..2dfe6c3 100644 --- a/repoview.go +++ b/repoview.go @@ -2,8 +2,8 @@ package main import ( "go.wit.com/lib/gadgets" - "go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/gowit" + "go.wit.com/lib/gui/repolist" "go.wit.com/log" "go.wit.com/gui" diff --git a/setTargetVersion.go b/setTargetVersion.go new file mode 100644 index 0000000..cf1090c --- /dev/null +++ b/setTargetVersion.go @@ -0,0 +1,67 @@ +package main + +import ( + "strings" + + "go.wit.com/log" +) + +func setTargetVersion() { + // go through and set the target versions for each repo + // todo: add sanity checking in repolist to verify these and/or autocompute them + // for now, just don't be stupid when you set your ENV vars + // widget I versioned early before I knew what the hell this would mean and can + // not be down versioned because that's not how GO versioning works. Once you + // set the version for a path, it's set in stone forever. (smart system!) + // we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning + // system, but that's rediculous and this servers to always remind me to never make this mistake again + var count int + for i, repo := range me.repos.View.AllRepos() { + if repo == nil { + log.Info("initial scan repo = nil", i) + continue + } + + if repo.Status == nil { + log.Info("repo.status == nil", repo.Name()) + continue + } + + if repo.GoPath() == "go.wit.com/widget" { + repo.Status.SetTargetVersion("v" + widgetVersion) + } else { + repo.Status.SetTargetVersion("v" + releaseVersion) + } + if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/") { + lasttag := repo.Status.GetLastTagVersion() + repo.Status.SetTargetVersion(lasttag) + } + // repo.NewScan() + count += 1 + } + log.Info("target versions set for", count, "repos") +} + +// trys to figure out if the version needs to be incremented +func incrementTargetVersion() bool { + var count int + for _, repo := range me.repos.View.AllRepos() { + if repo.ReadOnly() { + continue + } + lasttag := repo.Status.GetLastTagVersion() + master := repo.Status.GetMasterVersion() + + if lasttag != master { + log.Info("increment target version", repo.GoPath(), lasttag, master) + count += 1 + } else { + // check go dependancies for target version changes + } + } + log.Info("need to update target versions for", count, "repos") + if count == 0 { + return true + } + return false +}