2024-01-31 06:05:11 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-31 06:53:20 -06:00
|
|
|
"path/filepath"
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
"go.wit.com/lib/gui/repolist"
|
2024-01-31 06:05:11 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
func lookToUnwind(r *repolist.Repo) bool {
|
2024-02-18 17:55:59 -06:00
|
|
|
goSumS := r.GoState()
|
2024-02-18 15:09:04 -06:00
|
|
|
dirtyS := r.State()
|
|
|
|
currentS := r.Status.GetCurrentBranchVersion()
|
|
|
|
log.Info("repo:", r.Name(), goSumS, dirtyS, r.State(), currentS)
|
2024-01-31 06:05:11 -06:00
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
curName := r.Status.GetCurrentBranchName()
|
|
|
|
mName := r.Status.GetMasterBranchName()
|
2024-01-31 06:05:11 -06:00
|
|
|
|
|
|
|
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)
|
2024-02-18 17:55:59 -06:00
|
|
|
r.SetGoState("CAN NOT UNWIND")
|
2024-01-31 06:05:11 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
if r.LastTag() != currentS {
|
|
|
|
log.Info("\trepo version mismatch last vs current", r.LastTag(), "!=", currentS)
|
2024-02-18 17:55:59 -06:00
|
|
|
r.SetGoState("CAN NOT UNWIND")
|
2024-01-31 06:05:11 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
if release.version.String() != r.LastTag() {
|
|
|
|
log.Info("\trepo version mismatch last vs official", r.LastTag(), "!=", release.version.String())
|
2024-02-18 17:55:59 -06:00
|
|
|
r.SetGoState("CAN NOT UNWIND")
|
2024-01-31 06:05:11 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
fullpath := filepath.Join(me.goSrcPwd.String(), r.GoPath())
|
2024-01-31 06:53:20 -06:00
|
|
|
testf := filepath.Join(fullpath, "go.mod")
|
|
|
|
if Exists(testf) {
|
|
|
|
log.Info("\trepo is ready. go.mod exists")
|
2024-02-18 17:55:59 -06:00
|
|
|
r.SetGoState("UNWIND")
|
2024-01-31 06:53:20 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
fullpath = filepath.Join(me.GoSrcPath(), r.GoPath())
|
2024-01-31 06:53:20 -06:00
|
|
|
testf = filepath.Join(fullpath, "go.sum")
|
|
|
|
if Exists(testf) {
|
|
|
|
log.Info("\trepo is ready. go.sum exists")
|
2024-02-18 17:55:59 -06:00
|
|
|
r.SetGoState("UNWIND")
|
2024-01-31 06:53:20 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-02-18 17:55:59 -06:00
|
|
|
r.SetGoState("NO UNWIND?")
|
2024-01-31 06:53:20 -06:00
|
|
|
return false
|
2024-01-31 06:05:11 -06:00
|
|
|
}
|