summaryrefslogtreecommitdiff
path: root/lookForUnwind.go
blob: 1ca79548617092f8c402ceb0d3fd69f8e416d55a (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
// This is a simple example
package main

import (
	"path/filepath"

	"go.wit.com/log"
)

func (r *repo) lookToUnwind() bool {
	goSumS := r.getGoSumStatus()
	dirtyS := r.dirtyLabel.String()
	currentS := r.status.GetCurrentBranchVersion()
	log.Info("repo:", r.String(), goSumS, dirtyS, r.lastTag.String(), 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.setGoSumStatus("CAN NOT UNWIND")
		return false
	}

	if r.lastTag.String() != currentS {
		log.Info("\trepo version mismatch last vs current", r.lastTag.String(), "!=", currentS)
		r.setGoSumStatus("CAN NOT UNWIND")
		return false
	}

	if release.version.String() != r.lastTag.String() {
		log.Info("\trepo version mismatch last vs official", r.lastTag.String(), "!=", release.version.String())
		r.setGoSumStatus("CAN NOT UNWIND")
		return false
	}

	fullpath := filepath.Join(me.goSrcPwd.String(), r.String())
	testf := filepath.Join(fullpath, "go.mod")
	if Exists(testf) {
		log.Info("\trepo is ready. go.mod exists")
		r.setGoSumStatus("UNWIND")
		return true
	}

	fullpath = filepath.Join(me.goSrcPwd.String(), r.String())
	testf = filepath.Join(fullpath, "go.sum")
	if Exists(testf) {
		log.Info("\trepo is ready. go.sum exists")
		r.setGoSumStatus("UNWIND")
		return true
	}

	r.setGoSumStatus("NO UNWIND?")
	return false
}