Repotype() working somewhat

This commit is contained in:
Jeff Carr 2024-12-01 16:04:07 -06:00
parent 82935ae6b2
commit 412658698a
6 changed files with 60 additions and 19 deletions

View File

@ -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
}

View File

@ -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":

View File

@ -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 {

View File

@ -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

View File

@ -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 {

View File

@ -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)
}
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 {
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 {