2024-01-30 14:40:41 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-30 16:48:40 -06:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2024-01-30 14:40:41 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-01-31 04:10:54 -06:00
|
|
|
func ReCheckReady() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
- // allrepos map[string]*repo
|
|
|
|
-
|
|
|
|
- keys := make([]string, 0, len(me.allrepos))
|
|
|
|
- for key := range me.allrepos {
|
|
|
|
- keys = append(keys, key)
|
|
|
|
- }
|
|
|
|
- sort.Strings(keys)
|
|
|
|
-
|
|
|
|
- for _, path := range keys {
|
|
|
|
- repo := me.allrepos[path]
|
|
|
|
*/
|
|
|
|
|
2024-01-30 14:40:41 -06:00
|
|
|
func CheckReady() bool {
|
|
|
|
if release.current == nil {
|
|
|
|
log.Info("find the next repo first")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
goSumS := release.current.getGoSumStatus()
|
|
|
|
dirtyS := release.current.dirtyLabel.String()
|
|
|
|
lastS := release.current.status.GetLastTagVersion()
|
2024-01-31 04:10:54 -06:00
|
|
|
currentS := release.current.status.GetCurrentBranchVersion()
|
2024-01-31 16:39:42 -06:00
|
|
|
|
2024-02-01 13:30:26 -06:00
|
|
|
var targetS string
|
|
|
|
targetS = "v" + release.version.String()
|
|
|
|
log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS, currentS, targetS)
|
2024-01-30 14:40:41 -06:00
|
|
|
|
2024-01-31 04:10:54 -06:00
|
|
|
if goSumS == "PRIMATIVE" {
|
|
|
|
return true
|
|
|
|
}
|
2024-01-31 16:39:42 -06:00
|
|
|
if goSumS == "RELEASED" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if goSumS == "UNCHANGED" {
|
|
|
|
return true
|
|
|
|
}
|
2024-01-31 03:00:10 -06:00
|
|
|
if goSumS == "READY" {
|
2024-01-31 16:39:42 -06:00
|
|
|
if targetS == lastS {
|
2024-01-31 04:10:54 -06:00
|
|
|
release.current.setGoSumStatus("RELEASED")
|
2024-01-31 16:39:42 -06:00
|
|
|
return true
|
2024-01-31 04:10:54 -06:00
|
|
|
}
|
|
|
|
if lastS == currentS {
|
2024-01-31 16:39:42 -06:00
|
|
|
release.current.setGoSumStatus("UNCHANGED")
|
2024-01-31 04:10:54 -06:00
|
|
|
}
|
2024-01-31 03:00:10 -06:00
|
|
|
return true
|
|
|
|
}
|
2024-01-31 04:10:54 -06:00
|
|
|
release.current.setGoSumStatus("NOT READY")
|
2024-01-30 14:40:41 -06:00
|
|
|
if release.current.status.ReadOnly() {
|
|
|
|
log.Info("\trepo is read only")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-31 16:39:42 -06:00
|
|
|
if targetS == lastS {
|
|
|
|
log.Info("\trepo is already done", lastS, "=", targetS)
|
2024-01-31 04:10:54 -06:00
|
|
|
release.current.setGoSumStatus("READY")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if lastS == currentS {
|
2024-01-31 16:39:42 -06:00
|
|
|
log.Info("\trepo is already done", lastS, "=", targetS)
|
2024-01-31 04:10:54 -06:00
|
|
|
release.current.setGoSumStatus("READY")
|
|
|
|
return true
|
2024-01-30 14:40:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if goSumS == "BAD" {
|
2024-01-30 16:48:40 -06:00
|
|
|
log.Info("\trepo is ready", release.current.String(), "BAD == BAD")
|
2024-01-30 14:40:41 -06:00
|
|
|
} else {
|
2024-01-30 16:48:40 -06:00
|
|
|
log.Info("\trepo is ready maybe", release.current.String(), "BAD !=", goSumS)
|
2024-01-30 14:40:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if release.current.status.CheckDirty() {
|
|
|
|
log.Info("\trepo is dirty")
|
|
|
|
return false
|
|
|
|
} else {
|
2024-01-30 16:48:40 -06:00
|
|
|
log.Info("\trepo is ready", release.current.String(), "not dirty")
|
|
|
|
}
|
|
|
|
|
|
|
|
fullpath := filepath.Join(me.goSrcPwd.String(), release.current.String())
|
|
|
|
|
|
|
|
testf := filepath.Join(fullpath, "go.mod")
|
|
|
|
if Exists(testf) {
|
|
|
|
log.Info("\trepo is not ready. go.mod exists")
|
|
|
|
return false
|
2024-01-30 14:40:41 -06:00
|
|
|
}
|
|
|
|
|
2024-01-30 16:48:40 -06:00
|
|
|
testf = filepath.Join(fullpath, "go.sum")
|
|
|
|
if Exists(testf) {
|
|
|
|
log.Info("\trepo is not ready. go.sum exists")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
testf = filepath.Join(fullpath, "LICENSE")
|
2024-01-31 01:36:54 -06:00
|
|
|
if !Exists(testf) {
|
2024-01-30 16:48:40 -06:00
|
|
|
log.Info("\trepo is not ready. missing LICENSE")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// final checks here
|
|
|
|
if dirtyS == "ready to tag version" {
|
|
|
|
log.Info("\trepo is ready", release.current.String(), "ready to tag version")
|
|
|
|
} else {
|
2024-01-30 17:05:47 -06:00
|
|
|
log.Info("\trepo is not ready", dirtyS, "!= 'ready to tag version'")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
curName := release.current.status.GetCurrentBranchName()
|
|
|
|
mName := release.current.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)
|
2024-01-30 16:48:40 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-31 04:10:54 -06:00
|
|
|
release.current.setGoSumStatus("READY")
|
2024-01-30 16:48:40 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns true if the file exists
|
|
|
|
func Exists(file string) bool {
|
|
|
|
_, err := os.Stat(file)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
2024-01-30 14:40:41 -06:00
|
|
|
return true
|
|
|
|
}
|