summaryrefslogtreecommitdiff
path: root/validate
diff options
context:
space:
mode:
Diffstat (limited to 'validate')
-rw-r--r--validate/Makefile21
-rw-r--r--validate/argv.go42
-rw-r--r--validate/main.go97
3 files changed, 160 insertions, 0 deletions
diff --git a/validate/Makefile b/validate/Makefile
new file mode 100644
index 0000000..1e51eb6
--- /dev/null
+++ b/validate/Makefile
@@ -0,0 +1,21 @@
+VERSION = $(shell git describe --tags)
+BUILDTIME = $(shell date +%Y.%m.%d)
+
+build:
+ GO111MODULE=off go build \
+ -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+
+test:
+ ./validate --repo go.wit.com/apps/wit-package
+
+goimports:
+ goimports -w *.go
+
+prep:
+ go get -v -t -u
+
+run:
+ go run *.go
+
+clean:
+ -rm -f scanGoSrc
diff --git a/validate/argv.go b/validate/argv.go
new file mode 100644
index 0000000..35dd9a9
--- /dev/null
+++ b/validate/argv.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "os"
+
+ "go.wit.com/dev/alexflint/arg"
+)
+
+var argv args
+
+type args struct {
+ Repo string `arg:"--repo" help:"repo to check"`
+ List bool `arg:"--list" default:"false" help:"list repos in your config"`
+ SaveConfig bool `arg:"--save" default:"false" help:"save your config file at the end"`
+ Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
+}
+
+func (a args) Description() string {
+ return `
+ forgeConfig -- add entries to your config files
+
+This is just example protobuf code to test forgepb is working
+but it could be used to automagically create a config file too.
+
+If you need to change your config file, just edit the forge.text or forge.json
+files then remove the forge.pb and ConfigLoad() will attempt to load those files instead
+`
+}
+
+func (args) Version() string {
+ return "virtigo " + VERSION
+}
+
+func init() {
+ var pp *arg.Parser
+ pp = arg.MustParse(&argv)
+
+ if pp == nil {
+ pp.WriteHelp(os.Stdout)
+ os.Exit(0)
+ }
+}
diff --git a/validate/main.go b/validate/main.go
new file mode 100644
index 0000000..7c32ac6
--- /dev/null
+++ b/validate/main.go
@@ -0,0 +1,97 @@
+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()
+ if ! repo.IsValid() {
+ continue
+ }
+ // 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 %s\n", fullpath, mName, dName, uName, ds, ps, repo.RepoType())
+ /*
+ 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())
+ }
+ */
+ }
+
+ if argv.Repo == "" {
+ log.Info("no --repo")
+ os.Exit(-1)
+ }
+
+ check := forge.Repos.FindByGoPath(argv.Repo)
+ if check == nil {
+ log.Info("boo, you didn't git check", argv.Repo)
+ os.Exit(-1)
+ }
+ check.RedoGoMod()
+
+ match, err := forge.Repos.GoDepsChanged(check)
+ if err != nil {
+ log.Info("dependancy checks failed", check.GetGoPath(), err)
+ os.Exit(-1)
+ }
+ if match {
+ log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
+ } else {
+ log.Printf("dependancies have not changed for %s\n", check.GetGoPath())
+ }
+
+ if argv.SaveConfig {
+ forge.Repos.ConfigSave()
+ }
+
+ os.Exit(0)
+}