Repotype() working somewhat
This commit is contained in:
parent
82935ae6b2
commit
412658698a
|
@ -124,6 +124,22 @@ func (repo *Repo) parseGoSum() (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
func (repo *Repo) RepoType() string {
|
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")
|
os.Setenv("GO111MODULE", "off")
|
||||||
cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}
|
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
|
// 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
|
// returns true if the last published
|
||||||
func (all *Repos) GoDepsChanged(repo *Repo) (bool, error) {
|
func (all *Repos) GoDepsChanged(repo *Repo) (bool, error) {
|
||||||
var match bool = true
|
var upgrade bool = false
|
||||||
|
|
||||||
if repo.GoDeps == nil {
|
if repo.GoDeps == nil {
|
||||||
repo.RedoGoMod()
|
repo.RedoGoMod()
|
||||||
|
@ -238,9 +254,17 @@ func (all *Repos) GoDepsChanged(repo *Repo) (bool, error) {
|
||||||
}
|
}
|
||||||
found := repo.Published.FindByGoPath(depRepo.GetGoPath())
|
found := repo.Published.FindByGoPath(depRepo.GetGoPath())
|
||||||
if found == nil {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (all *Repos) NewGoPath(basepath string, gopath string) (*Repo, error) {
|
||||||
newr.GoDeps = new(GoDeps)
|
newr.GoDeps = new(GoDeps)
|
||||||
// newr.RedoGoMod()
|
// newr.RedoGoMod()
|
||||||
|
|
||||||
switch newr.RepoType() {
|
switch newr.goListRepoType() {
|
||||||
case "library":
|
case "library":
|
||||||
newr.GoLibrary = true
|
newr.GoLibrary = true
|
||||||
case "binary":
|
case "binary":
|
||||||
|
|
7
shell.go
7
shell.go
|
@ -61,6 +61,13 @@ func (repo *Repo) Exists(filename string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repo) IsValid() bool {
|
||||||
|
if !repo.IsDirectory() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *Repo) IsDirectory() bool {
|
func (repo *Repo) IsDirectory() bool {
|
||||||
info, err := os.Stat(repo.FullPath)
|
info, err := os.Stat(repo.FullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -5,7 +5,7 @@ build:
|
||||||
reset
|
reset
|
||||||
GO111MODULE=off go build \
|
GO111MODULE=off go build \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
./validate
|
./validate --repo go.wit.com/apps/wit-package
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
|
|
@ -9,9 +9,10 @@ import (
|
||||||
var argv args
|
var argv args
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
List bool `arg:"--list" default:"false" help:"list repos in your config"`
|
Repo string `arg:"--repo" help:"repo to check"`
|
||||||
SaveConfig bool `arg:"--save" default:"false" help:"save your config file at the end"`
|
List bool `arg:"--list" default:"false" help:"list repos in your config"`
|
||||||
Interesting bool `arg:"--interesting" default:"false" help:"something you decided was cool"`
|
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 {
|
func (a args) Description() string {
|
||||||
|
|
|
@ -35,6 +35,9 @@ func main() {
|
||||||
repos := forge.Repos.SortByGoPath()
|
repos := forge.Repos.SortByGoPath()
|
||||||
for repos.Scan() {
|
for repos.Scan() {
|
||||||
repo := repos.Next()
|
repo := repos.Next()
|
||||||
|
if ! repo.IsValid() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// forge.VerifyBranchNames(repo)
|
// forge.VerifyBranchNames(repo)
|
||||||
fullpath := repo.GetFullPath()
|
fullpath := repo.GetFullPath()
|
||||||
mName := repo.GetMasterBranchName()
|
mName := repo.GetMasterBranchName()
|
||||||
|
@ -44,16 +47,16 @@ func main() {
|
||||||
plen := repo.PublishedLen()
|
plen := repo.PublishedLen()
|
||||||
var ds, ps string
|
var ds, ps string
|
||||||
if dlen == 0 {
|
if dlen == 0 {
|
||||||
ds = ""
|
ds = " "
|
||||||
} else {
|
} else {
|
||||||
ds = fmt.Sprintf("%2d", dlen)
|
ds = fmt.Sprintf("%2d", dlen)
|
||||||
}
|
}
|
||||||
if plen == 0 {
|
if plen == 0 {
|
||||||
ps = ""
|
ps = " "
|
||||||
} else {
|
} else {
|
||||||
ps = fmt.Sprintf("%2d", plen)
|
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() {
|
if repo.GoDepsChanged() {
|
||||||
log.Printf("\tdependancy checks indicate a new release is needed for %s\n", repo.GetGoPath())
|
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 argv.Repo == "" {
|
||||||
if goclone == nil {
|
log.Info("no --repo")
|
||||||
log.Info("boo, you didn't git go-clone?")
|
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
match, err := forge.Repos.GoDepsChanged(goclone)
|
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 {
|
if err != nil {
|
||||||
log.Info("dependancy checks failed", goclone.GetGoPath(), err)
|
log.Info("dependancy checks failed", check.GetGoPath(), err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
if match {
|
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 {
|
} 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 {
|
if argv.SaveConfig {
|
||||||
|
|
Loading…
Reference in New Issue