summaryrefslogtreecommitdiff
path: root/validate/main.go
blob: 57329effdf5736fbf6c03b662fd9d1b069371d72 (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
package main

import (
	"fmt"
	"os"

	"go.wit.com/dev/alexflint/arg"
	"go.wit.com/gui"
	"go.wit.com/lib/gui/repolist"
	"go.wit.com/lib/protobuf/forgepb"
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

// sent via ldflags
var VERSION string

var pp *arg.Parser
var forge *forgepb.Forge
var myGui *gui.Node
var rv *repolist.RepoList
var argvRepo *gitpb.Repo

func main() {
	pp = arg.MustParse(&argv)

	// load the ~/.config/forge/ config
	forge = forgepb.Init()
	// forge.ConfigPrintTable()
	os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())

	myGui = gui.New()
	myGui.Default()

	repos := forge.Repos.SortByGoPath()
	for repos.Scan() {
		repo := repos.Next()
		// forge.VerifyBranchNames(repo)
		fullpath := repo.GetFullPath()
		mName := repo.GetMasterBranchName()
		dName := repo.GetDevelBranchName()
		uName := repo.GetUserBranchName()
		dlen := repo.GoDepsLen()
		plen := repo.PublishedLen()
		var ds, ps string
		if dlen == 0 {
			ds = ""
		} else {
			ds = fmt.Sprintf("%2d", dlen)
		}
		if plen == 0 {
			ps = ""
		} else {
			ps = fmt.Sprintf("%2d", plen)
		}
		log.Printf("repo: %-60s %-10s %-8s %-8s %s %s\n", fullpath, mName, dName, uName, ds, ps)
		/*
			if repo.GoDepsChanged() {
				log.Printf("\tdependancy checks indicate a new release is needed for %s\n", repo.GetGoPath())
			} else {
				log.Printf("\tdependancies have not changed for %s\n", repo.GetGoPath())
			}
		*/
	}

	goclone := forge.Repos.FindByGoPath("go.wit.com/apps/go-clone")
	if goclone == nil {
		log.Info("boo, you didn't git go-clone?")
		os.Exit(-1)
	}

	match, err := forge.Repos.GoDepsChanged(goclone)
	if err != nil {
		log.Info("dependancy checks failed", goclone.GetGoPath(), err)
		os.Exit(-1)
	}
	if match {
		log.Printf("dependancy checks indicate a new release is needed for %s\n", goclone.GetGoPath())
	} else {
		log.Printf("dependancies have not changed for %s\n", goclone.GetGoPath())
	}

	if argv.SaveConfig {
		forge.Repos.ConfigSave()
	}

	os.Exit(0)
}