// This is a simple example package main import ( "os" "path/filepath" "go.wit.com/log" ) 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] */ 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() currentS := release.current.status.GetCurrentBranchVersion() var targetS string targetS = release.version.String() log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS, currentS, targetS) if goSumS == "RELEASED" { return true } if goSumS == "PRIMATIVE" { if targetS == lastS { release.current.setGoSumStatus("RELEASED") } return true } if goSumS == "UNRELEASED" { return true } if goSumS == "READY" { if targetS == lastS { release.current.setGoSumStatus("RELEASED") return true } if lastS == currentS { release.current.setGoSumStatus("UNRELEASED") } return true } release.current.setGoSumStatus("NOT READY") if release.current.status.ReadOnly() { log.Info("\trepo is read only") return false } if targetS == lastS { log.Info("\trepo is already done", lastS, "=", targetS) release.current.setGoSumStatus("READY") return true } if lastS == currentS { log.Info("\trepo is already done", lastS, "=", targetS) release.current.setGoSumStatus("READY") return true } if goSumS == "BAD" { log.Info("\trepo is ready", release.current.String(), "BAD == BAD") } else { log.Info("\trepo is ready maybe", release.current.String(), "BAD !=", goSumS) } if release.current.status.CheckDirty() { log.Info("\trepo is dirty") return false } else { 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 } 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") if !Exists(testf) { 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 { 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) return false } release.current.setGoSumStatus("READY") return true } // returns true if the file exists func Exists(file string) bool { _, err := os.Stat(file) if err != nil { return false } return true }