diff options
Diffstat (limited to 'checkReady.go')
| -rw-r--r-- | checkReady.go | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/checkReady.go b/checkReady.go deleted file mode 100644 index 69f42f8..0000000 --- a/checkReady.go +++ /dev/null @@ -1,126 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - - "go.wit.com/log" -) - -func CheckReady() bool { - if me.current == nil { - log.Info("find the next repo first") - return false - } - goSumS := me.current.GoState() - dirtyS := me.current.State() - lastS := me.current.Status.GetLastTagVersion() - currentS := me.current.Status.GetCurrentBranchVersion() - - var targetS string - targetS = me.release.version.String() - - log.Info("repo:", me.current.State(), goSumS, dirtyS, lastS, currentS, targetS) - - if goSumS == "RELEASED" { - return true - } - if me.current.Status.IsPrimitive() { - if targetS == lastS { - me.current.SetGoState("RELEASED") - } - return true - } - if goSumS == "UNRELEASED" { - return true - } - if goSumS == "READY" { - if targetS == lastS { - me.current.SetGoState("RELEASED") - return true - } - if lastS == currentS { - me.current.SetGoState("UNRELEASED") - } - return true - } - me.current.SetGoState("NOT READY") - if me.current.Status.ReadOnly() { - log.Info("\trepo is read only") - return false - } - - if targetS == lastS { - log.Info("\trepo is already done", lastS, "=", targetS) - me.current.SetGoState("READY") - return true - } - if lastS == currentS { - log.Info("\trepo is already done", lastS, "=", targetS) - me.current.SetGoState("READY") - return true - } - - if goSumS == "BAD" { - log.Info("\trepo is ready", me.current.State(), "BAD == BAD") - } else { - log.Info("\trepo is ready maybe", me.current.State(), "BAD !=", goSumS) - } - - if me.current.Status.CheckDirty() { - log.Info("\trepo is dirty") - return false - } else { - log.Info("\trepo is ready", me.current.State(), "not dirty") - } - - fullpath := filepath.Join(me.goSrcPwd.String(), me.current.State()) - - 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 == "unchanged" { - log.Info("\trepo is ready", me.current.Name(), "unchanged") - } else { - log.Info("\trepo is not ready", dirtyS, "!= 'unchanged'") - return false - } - - curName := me.current.Status.GetCurrentBranchName() - mName := me.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 - } - - me.current.SetGoState("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 -} |
