From 22d2ae5cd79791ca5d70e2f6670d20a8d5e36984 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 18 Dec 2024 18:51:51 -0600 Subject: [PATCH] is primitive fixes --- goDep.parseGoSum.go | 9 ++++++--- isPrimitive.go | 23 +++++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/goDep.parseGoSum.go b/goDep.parseGoSum.go index e7bd1a9..b2b3d04 100644 --- a/goDep.parseGoSum.go +++ b/goDep.parseGoSum.go @@ -18,11 +18,14 @@ func (repo *Repo) ParseGoSum() (bool, error) { // empty out what was there before repo.GoDeps = nil - // check of the repo is a primative + // check of the repo is a primitive // that means, there is not a go.sum file // because the package is completely self contained! - if err := repo.SetPrimitive(); err == nil { - log.Info("This repo is primative!") + if err := repo.SetPrimitive(); err != nil { + return false, err + } + if repo.GetGoPrimitive() { + log.Info("This repo is primitive!") return true, nil } tmp := filepath.Join(repo.FullPath, "go.sum") diff --git a/isPrimitive.go b/isPrimitive.go index a3ecbba..6ce67f8 100644 --- a/isPrimitive.go +++ b/isPrimitive.go @@ -22,13 +22,13 @@ func (repo *Repo) SetPrimitive() error { return err } -// Detect a 'Primative' package. Sets the isPrimative flag +// Detect a 'Primitive' package. Sets the isPrimitive flag // will return true if the repo is truly not dependent on _anything_ else // like spew or lib/widget // it assumes go mod ran init and tidy ran without error func (repo *Repo) computePrimitive() (bool, error) { // go mod init & go mod tidy ran without errors - log.Log(GITPB, "isPrimativeGoMod()", repo.FullPath) + log.Log(GITPB, "isPrimitiveGoMod()", repo.FullPath) tmp := filepath.Join(repo.FullPath, "go.mod") gomod, err := os.Open(tmp) if err != nil { @@ -37,6 +37,11 @@ func (repo *Repo) computePrimitive() (bool, error) { } defer gomod.Close() + if repo.Exists("go.sum") { + repo.GoInfo.GoPrimitive = false + return false, nil + } + scanner := bufio.NewScanner(gomod) for scanner.Scan() { line := strings.TrimSpace(scanner.Text()) @@ -47,14 +52,16 @@ func (repo *Repo) computePrimitive() (bool, error) { log.Log(GITPB, " gomod: part[0] =", parts[0]) if parts[0] == "require" { log.Log(GITPB, " should return false here") - return false, errors.New("go.mod file is not primative") + return false, errors.New("go.mod file is not primitive") } - if parts[0] == "go" { - if parts[1] != "1.21" { - log.Log(GITPBWARN, "go not set to 1.21 for", repo.GetGoPath()) - // return false, errors.New("go not set to 1.21 for " + repo.GetGoPath()) + /* + if parts[0] == "go" { + if parts[1] != "1.21" { + log.Log(GITPBWARN, "go not set to 1.21 for", repo.GetGoPath()) + // return false, errors.New("go not set to 1.21 for " + repo.GetGoPath()) + } } - } + */ } } repo.GoInfo.GoPrimitive = true