summaryrefslogtreecommitdiff
path: root/scanGoSum.go
blob: 87018089922f08cd0aaae2f70c451678667eb6ba (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This is a simple example
package main

import (
	"go.wit.com/log"
)

func (r *repo) getGoSumStatus() string {
	return r.goSumStatus.String()
}

func (r *repo) setGoSumStatus(s string) {
	r.goSumStatus.SetLabel(s)
	r.status.SetGoSumStatus(s)
}

func (r *repo) checkDirty() bool {
	if r.status.CheckDirty() {
		log.Info("dirty repo:", r.status.String(), r.getGoSumStatus())
		r.setGoSumStatus("DIRTY")
		return true
	}
	return false
}

func (r *repo) checkSafeGoSumRemake() {
	if ok, bad := r.status.CheckSafeGoSumRemake(); ok {
		log.Info("checkSafeGoSumRemake() is safe to redo")
		r.setGoSumStatus("SAFE")
		r.status.MakeRedomod()
	} else {
		log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
		r.setGoSumStatus("BAD DEP")
	}
}

func scanGoSum() {
	for _, repo := range me.allrepos {
		if repo.String() == "go.wit.com/apps/guireleaser" {
			if release.guireleaser == nil {
				release.guireleaser = repo
			}
		}
		latestversion := repo.status.GetLastTagVersion()
		if repo.getGoSumStatus() == "BAD" {
			continue
		}
		if repo.getGoSumStatus() == "DIRTY" {
			continue
		}
		if repo.status.CheckPrimativeGoMod() {
			log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
			repo.setGoSumStatus("PRIMATIVE")
			continue
		}
		if repo.checkDirty() {
			log.Info("dirty repo:", latestversion, repo.status.String())
			log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
			repo.setGoSumStatus("DIRTY")

			// release.repo.SetValue(repo.status.String())
			// release.status.SetValue("dirty")
			// release.notes.SetValue("You must commit your changes\nbefore you can continue")
			// release.current = repo
			// release.openrepo.Enable()
			continue
		}
		if ok, missing := repo.status.CheckGoSum(); ok {
			log.Info("repo has go.sum requirements that are clean")
			repo.setGoSumStatus("CLEAN")
		} else {
			log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
			repo.setGoSumStatus("BAD")

			// release.repo.SetValue(repo.status.String())
			// release.status.SetValue("bad")
			// release.notes.SetValue("the go.sum file is wrong")
			// release.current = repo
			// release.openrepo.Enable()
			continue
		}
		status := repo.dirtyLabel.String()
		if status == "PERFECT" {
			continue
		} else {
			repo.newScan()
		}

		log.Info("repo:", latestversion, status, repo.status.String())
	}
	log.Info("scanGoSum() did everything, not sure what to do next")
}