summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--goDep.redoGoMod.go32
-rw-r--r--repo.new.go2
-rw-r--r--shell.go7
-rw-r--r--validate/Makefile2
-rw-r--r--validate/argv.go7
-rw-r--r--validate/main.go29
6 files changed, 60 insertions, 19 deletions
diff --git a/goDep.redoGoMod.go b/goDep.redoGoMod.go
index 72249fe..d75f32a 100644
--- a/goDep.redoGoMod.go
+++ b/goDep.redoGoMod.go
@@ -124,6 +124,22 @@ func (repo *Repo) parseGoSum() (bool, error) {
return true, nil
}
func (repo *Repo) RepoType() string {
+ if repo.GetGoPlugin() {
+ return "plugin"
+ }
+ if repo.GetGoBinary() {
+ return "binary"
+ }
+ if ok, _, _ := repo.IsProtobuf(); ok {
+ return "protobuf"
+ }
+ if repo.GetGoLibrary() {
+ return "library"
+ }
+ return ""
+}
+
+func (repo *Repo) goListRepoType() string {
os.Setenv("GO111MODULE", "off")
cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}
// cmd := []string{"go", "list", "-f", "'{{.Name}}'"} // probably use this. this just prints out the package name
@@ -221,7 +237,7 @@ func (repo *Repo) PublishedLen() int {
// returns true if the last published
func (all *Repos) GoDepsChanged(repo *Repo) (bool, error) {
- var match bool = true
+ var upgrade bool = false
if repo.GoDeps == nil {
repo.RedoGoMod()
@@ -238,9 +254,17 @@ func (all *Repos) GoDepsChanged(repo *Repo) (bool, error) {
}
found := repo.Published.FindByGoPath(depRepo.GetGoPath())
if found == nil {
- return true, errors.New("new repo added " + depRepo.GetGoPath())
+ log.Printf("dep %-50s %-10s vs %-10s", depRepo.GetGoPath(), depRepo.GetVersion(), "NEW")
+ upgrade = true
+ continue
+ // return upgrade, errors.New("new repo added " + depRepo.GetGoPath())
+ }
+ if depRepo.GetVersion() == found.GetVersion() {
+ // log.Printf("deps %-50s %-10s vs %-10s", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetVersion())
+ } else {
+ log.Printf("dep %-50s %-10s vs %-10s BROKEN", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetVersion())
+ upgrade = true
}
- log.Printf("deps %-50s %-10s vs %-10s", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetVersion())
}
- return match, nil
+ return upgrade, nil
}
diff --git a/repo.new.go b/repo.new.go
index 0246ddf..5d774fe 100644
--- a/repo.new.go
+++ b/repo.new.go
@@ -39,7 +39,7 @@ func (all *Repos) NewGoPath(basepath string, gopath string) (*Repo, error) {
newr.GoDeps = new(GoDeps)
// newr.RedoGoMod()
- switch newr.RepoType() {
+ switch newr.goListRepoType() {
case "library":
newr.GoLibrary = true
case "binary":
diff --git a/shell.go b/shell.go
index 8724a34..2bde405 100644
--- a/shell.go
+++ b/shell.go
@@ -61,6 +61,13 @@ func (repo *Repo) Exists(filename string) bool {
return true
}
+func (repo *Repo) IsValid() bool {
+ if !repo.IsDirectory() {
+ return false
+ }
+ return true
+}
+
func (repo *Repo) IsDirectory() bool {
info, err := os.Stat(repo.FullPath)
if err != nil {
diff --git a/validate/Makefile b/validate/Makefile
index 24a62b6..c287e2e 100644
--- a/validate/Makefile
+++ b/validate/Makefile
@@ -5,7 +5,7 @@ build:
reset
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
- ./validate
+ ./validate --repo go.wit.com/apps/wit-package
goimports:
goimports -w *.go
diff --git a/validate/argv.go b/validate/argv.go
index c46149b..35dd9a9 100644
--- a/validate/argv.go
+++ b/validate/argv.go
@@ -9,9 +9,10 @@ import (
var argv args
type args struct {
- 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"`
+ 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 {
diff --git a/validate/main.go b/validate/main.go
index 57329ef..7c32ac6 100644
--- a/validate/main.go
+++ b/validate/main.go
@@ -35,6 +35,9 @@ func main() {
repos := forge.Repos.SortByGoPath()
for repos.Scan() {
repo := repos.Next()
+ if ! repo.IsValid() {
+ continue
+ }
// forge.VerifyBranchNames(repo)
fullpath := repo.GetFullPath()
mName := repo.GetMasterBranchName()
@@ -44,16 +47,16 @@ func main() {
plen := repo.PublishedLen()
var ds, ps string
if dlen == 0 {
- ds = ""
+ ds = " "
} else {
ds = fmt.Sprintf("%2d", dlen)
}
if plen == 0 {
- ps = ""
+ ps = " "
} else {
ps = fmt.Sprintf("%2d", plen)
}
- log.Printf("repo: %-60s %-10s %-8s %-8s %s %s\n", fullpath, mName, dName, uName, ds, ps)
+ 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())
@@ -63,21 +66,27 @@ func main() {
*/
}
- goclone := forge.Repos.FindByGoPath("go.wit.com/apps/go-clone")
- if goclone == nil {
- log.Info("boo, you didn't git go-clone?")
+ 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(goclone)
+ match, err := forge.Repos.GoDepsChanged(check)
if err != nil {
- log.Info("dependancy checks failed", goclone.GetGoPath(), err)
+ 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", goclone.GetGoPath())
+ 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", goclone.GetGoPath())
+ log.Printf("dependancies have not changed for %s\n", check.GetGoPath())
}
if argv.SaveConfig {