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

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

/*
func getGoSumStatus(r *repolist.Repo) string {
	return r.Status.GoSumStatus.String()
}

func setGoSumStatus(r *repolist.Repo, s string) {
	r.goSumStatus.SetLabel(s)
	r.status.SetGoSumStatus(s)
}
*/

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

func scanGoSum() {
	for _, repo := range me.repos.View.AllRepos() {
		if repo.GoPath() == "go.wit.com/apps/guireleaser" {
			if release.guireleaser == nil {
				release.guireleaser = repo
			}
		}
		latestversion := repo.Status.GetLastTagVersion()
		if repo.GoState() == "BAD" {
			continue
		}
		if repo.GoState() == "DIRTY" {
			continue
		}
		if repo.Status.CheckPrimativeGoMod() {
			log.Info("PRIMATIVE repo:", latestversion, repo.GoPath())
			repo.SetGoState("PRIMATIVE")
			continue
		}
		if repo.CheckDirty() {
			log.Info("dirty repo:", latestversion, repo.GoPath())
			log.Info("dirty repo.getGoSumStatus =", repo.GoState())
			repo.SetGoState("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.SetGoState("CLEAN")
		} else {
			log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
			repo.SetGoState("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.State()
		if status == "PERFECT" {
			continue
		} else {
			repo.NewScan()
		}

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