summaryrefslogtreecommitdiff
path: root/goDebCheck.go
blob: 793397f34ad5cbdf41fa38d4cca09697838bd8da (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
package forgepb

import (
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

// this is a final check to make sure, before pushing
// a golang repo, that the go.sum file has the correct
// and current version of every package
//
// it re-scans the go.sum file. DOES NOT MODIFY ANYTHING
// this is the last thing to run to double check everything
// before 'git tag' or git push --tags
func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool {
	var good bool = true
	if check == nil {
		log.Info("boo, check == nil")
		return false
	}
	// clear out the protobuf and rescan from the file
	check.GoDeps = nil
	if ok, err := check.ParseGoSum(); ! ok {
		log.Info("FinalGoDepsCheckOk() error", err)
		return false
	}

	if check.GoDepsLen() == 0 {
		// this is a primitive
		check.GoPrimitive = true
		return true
	}

	log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
	deps := check.GoDeps.SortByGoPath()
	for deps.Scan() {
		depRepo := deps.Next()
		found := f.Repos.FindByGoPath(depRepo.GetGoPath())
		if found == nil {
			log.Info("not found:", depRepo.GetGoPath())
			return false
		}
		// log.Info("found dep", depRepo.GetGoPath())
		if depRepo.GetVersion() != found.GetTargetVersion() {
			if f.IsReadOnly(depRepo.GetGoPath()) {
				log.Printf("%-48s  ok error %10s vs %10s (ignoring read-only repo)", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
			} else {
				log.Printf("%-48s     error %10s vs %10s", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
				good = false
			}
		}
	}
	return good
}