summaryrefslogtreecommitdiff
path: root/lookForUnwind.go
blob: e1956339e87f3c5e582a7c4eed4ef60765724d09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// This is a simple example
package main

import (
	"path/filepath"

	"go.wit.com/lib/gui/repolist"
	"go.wit.com/log"
)

func lookToUnwind(r *repolist.RepoRow) 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
}