2024-12-01 17:36:34 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
|
|
|
|
"go.wit.com/lib/gui/repolist"
|
|
|
|
)
|
|
|
|
|
|
|
|
// trys to figure out if there is still something to update
|
|
|
|
// todo: redo this logic as it is terrible
|
|
|
|
// rename this findNext()
|
|
|
|
func findNext() bool {
|
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
|
|
|
if repo.Status.IsReleased() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.Status.Whitelist {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.ReadOnly() {
|
|
|
|
// log.Info("findNext() skipping readonly")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.CheckDirty() {
|
|
|
|
log.Info("findNext() skipping dirty")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// do makeredomod here
|
|
|
|
// if ! repo.Status.Exists("go.sum") {
|
|
|
|
// }
|
|
|
|
if repo.Status.IsPrimitive() {
|
|
|
|
log.Info("findNext()", repo.GoPath())
|
|
|
|
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
log.Info("findNext()", repo.GoPath(), "is not a primative repo")
|
2024-12-02 05:13:17 -06:00
|
|
|
check := me.forge.Repos.FindByGoPath(repo.GoPath())
|
|
|
|
if check == nil {
|
|
|
|
log.Info("boo, you didn't git clone", repo.GoPath())
|
|
|
|
return false
|
2024-12-01 17:36:34 -06:00
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
if me.forge.FinalGoDepsCheck(check) {
|
2024-12-01 17:36:34 -06:00
|
|
|
setCurrentRepo(repo, "should be good to release", "pretty sure")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Info("tried to findNext() but not sure what to do next")
|
|
|
|
me.release.status.SetText("ALL DONE?")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-12-02 05:13:17 -06:00
|
|
|
/*
|
2024-12-01 17:36:34 -06:00
|
|
|
func checkValidGoSum(repo *repolist.RepoRow) bool {
|
2024-12-02 05:13:17 -06:00
|
|
|
if goodGodeps(repo) {
|
2024-12-01 17:36:34 -06:00
|
|
|
log.Info("repo has go.sum requirements that are clean")
|
|
|
|
// me.current.setGoSumStatus("CLEAN")
|
|
|
|
me.release.status.SetValue("GOOD")
|
|
|
|
me.release.notes.SetValue("CheckValidGoSum() does not seem to lie")
|
|
|
|
return true
|
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
log.Info("go mod tidy not ok")
|
2024-12-01 17:36:34 -06:00
|
|
|
me.release.notes.SetValue("CheckValidGoSum() failed")
|
|
|
|
return false
|
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
*/
|
2024-12-01 17:36:34 -06:00
|
|
|
|
|
|
|
func goodGodeps(repo *repolist.RepoRow) bool {
|
|
|
|
var good bool = true
|
|
|
|
// check if the package dependancies changed, if so, re-publish
|
|
|
|
check := me.forge.Repos.FindByGoPath(repo.GoPath())
|
|
|
|
if check == nil {
|
|
|
|
log.Info("boo, you didn't git clone", repo.GoPath())
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
// check.RedoGoMod()
|
2024-12-01 17:36:34 -06:00
|
|
|
log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
|
|
|
|
deps := check.GoDeps.SortByGoPath()
|
|
|
|
for deps.Scan() {
|
|
|
|
depRepo := deps.Next()
|
|
|
|
// log.Info("found dep", depRepo.GetGoPath())
|
|
|
|
if me.forge.IsReadOnly(depRepo.GetGoPath()) {
|
|
|
|
// log.Info("IsReadOnly = true", depRepo.GetGoPath())
|
|
|
|
continue
|
|
|
|
} else {
|
|
|
|
// log.Info("IsReadOnly = false", depRepo.GetGoPath())
|
|
|
|
}
|
|
|
|
found := me.repos.View.FindByPath(depRepo.GetGoPath())
|
|
|
|
if found == nil {
|
|
|
|
// log.Info("repos.View.FindByPath() not found", depRepo.GetGoPath())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if found.Status.IsReleased() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
header := found.StandardReleaseHeader()
|
|
|
|
log.Info("bad", header)
|
|
|
|
good = false
|
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
return good
|
|
|
|
}
|
2024-12-01 17:36:34 -06:00
|
|
|
|
2024-12-02 05:13:17 -06:00
|
|
|
// tries to fix the go.mod and go.sum files
|
|
|
|
func fixGodeps(repo *repolist.RepoRow) bool {
|
|
|
|
var good bool = true
|
|
|
|
// check if the package dependancies changed, if so, re-publish
|
|
|
|
check := me.forge.Repos.FindByGoPath(repo.GoPath())
|
|
|
|
if check == nil {
|
|
|
|
log.Info("boo, you didn't git clone", repo.GoPath())
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
2024-12-02 07:00:28 -06:00
|
|
|
// skip primative ones
|
|
|
|
if check.GetGoPrimitive() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
ok, err := check.RedoGoMod()
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
log.Info("gitpb.RedoGoMod() returned false", check.GetGoPath())
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if check.GoDeps == nil {
|
|
|
|
cmd := []string{"go", "mod", "edit", "-go=1.20"}
|
|
|
|
check.Run(cmd)
|
|
|
|
return true
|
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
|
|
|
|
deps := check.GoDeps.SortByGoPath()
|
|
|
|
for deps.Scan() {
|
|
|
|
depRepo := deps.Next()
|
|
|
|
// log.Info("found dep", depRepo.GetGoPath())
|
|
|
|
if me.forge.IsReadOnly(depRepo.GetGoPath()) {
|
|
|
|
log.Info("IsReadOnly = true", depRepo.GetGoPath())
|
2024-12-01 17:36:34 -06:00
|
|
|
continue
|
2024-12-02 05:13:17 -06:00
|
|
|
} else {
|
|
|
|
// log.Info("IsReadOnly = false", depRepo.GetGoPath())
|
|
|
|
}
|
|
|
|
found := me.repos.View.FindByPath(depRepo.GetGoPath())
|
|
|
|
if found == nil {
|
|
|
|
log.Info("not found:", depRepo.GetGoPath())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if depRepo.GetVersion() != found.Status.GetMasterVersion() {
|
|
|
|
log.Printf("%-48s %10s (from gitpb)", depRepo.GetGoPath(), depRepo.GetVersion())
|
|
|
|
header := found.StandardReleaseHeader()
|
|
|
|
log.Info(header, "(from repolist)")
|
|
|
|
cmd := []string{"go", "get", depRepo.GetGoPath() + "@latest"}
|
|
|
|
check.Run(cmd)
|
2024-12-01 17:36:34 -06:00
|
|
|
}
|
|
|
|
}
|
2024-12-02 05:13:17 -06:00
|
|
|
cmd := []string{"go", "mod", "tidy"}
|
|
|
|
check.Run(cmd)
|
|
|
|
cmd = []string{"go", "mod", "edit", "-go=1.20"}
|
|
|
|
check.Run(cmd)
|
|
|
|
check.GoDeps = nil
|
|
|
|
check.ParseGoSum()
|
2024-12-01 17:36:34 -06:00
|
|
|
|
2024-12-02 05:13:17 -06:00
|
|
|
deps = check.GoDeps.SortByGoPath()
|
|
|
|
for deps.Scan() {
|
|
|
|
depRepo := deps.Next()
|
|
|
|
log.Info("found updated dep", depRepo.GetGoPath(), depRepo.GetVersion())
|
|
|
|
}
|
2024-12-01 17:36:34 -06:00
|
|
|
return good
|
|
|
|
}
|