guireleaser/lookForUnwind.go

59 lines
1.4 KiB
Go

// This is a simple example
package main
import (
"path/filepath"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func lookToUnwind(r *repolist.Repo) bool {
goSumS := r.GoState()
dirtyS := r.State()
currentS := r.Status.GetCurrentBranchVersion()
log.Info("repo:", r.Name(), goSumS, dirtyS, r.State(), currentS)
curName := r.Status.GetCurrentBranchName()
mName := r.Status.GetMasterBranchName()
if curName == mName {
log.Info("\trepo is ready working from main branch", curName, "=", mName)
} else {
log.Info("\trepo is not ready main branch", curName, "!=", mName)
r.SetGoState("CAN NOT UNWIND")
return false
}
if r.LastTag() != currentS {
log.Info("\trepo version mismatch last vs current", r.LastTag(), "!=", currentS)
r.SetGoState("CAN NOT UNWIND")
return false
}
if me.release.version.String() != r.LastTag() {
log.Info("\trepo version mismatch last vs official", r.LastTag(), "!=", me.release.version.String())
r.SetGoState("CAN NOT UNWIND")
return false
}
fullpath := filepath.Join(me.goSrcPwd.String(), r.GoPath())
testf := filepath.Join(fullpath, "go.mod")
if Exists(testf) {
log.Info("\trepo is ready. go.mod exists")
r.SetGoState("UNWIND")
return true
}
fullpath = filepath.Join(me.GoSrcPath(), r.GoPath())
testf = filepath.Join(fullpath, "go.sum")
if Exists(testf) {
log.Info("\trepo is ready. go.sum exists")
r.SetGoState("UNWIND")
return true
}
r.SetGoState("NO UNWIND?")
return false
}