From 97a2f05cf2e0c09e8576db089950483a48afea71 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 3 Dec 2024 18:03:54 -0600 Subject: rename --- goDep.isPrimitive.go | 48 ------------------------------------------------ goDep.redoGoMod.go | 3 +-- isPrimitive.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ shell.go | 1 + 4 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 goDep.isPrimitive.go create mode 100644 isPrimitive.go diff --git a/goDep.isPrimitive.go b/goDep.isPrimitive.go deleted file mode 100644 index a894ecd..0000000 --- a/goDep.isPrimitive.go +++ /dev/null @@ -1,48 +0,0 @@ -package gitpb - -// only reads in the go.mod file. doesn't change anything - -import ( - "bufio" - "errors" - "os" - "path/filepath" - "strings" - - "go.wit.com/log" -) - -// Detect a 'Primative' package. Sets the isPrimative 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) isPrimativeGoMod() (bool, error) { - // go mod init & go mod tidy ran without errors - log.Log(GITPB, "isPrimativeGoMod()", repo.FullPath) - tmp := filepath.Join(repo.FullPath, "go.mod") - gomod, err := os.Open(tmp) - if err != nil { - log.Log(GITPB, "missing go.mod", repo.FullPath) - return false, err - } - defer gomod.Close() - - scanner := bufio.NewScanner(gomod) - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - - parts := strings.Split(line, " ") - log.Log(GITPB, " gomod:", parts) - if len(parts) >= 1 { - 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") - } - - } - } - repo.GoPrimitive = true - repo.GoDeps = nil - return true, nil -} diff --git a/goDep.redoGoMod.go b/goDep.redoGoMod.go index 8bb8058..7e56989 100644 --- a/goDep.redoGoMod.go +++ b/goDep.redoGoMod.go @@ -52,7 +52,7 @@ func (repo *Repo) RedoGoMod() (bool, error) { repo.GoDeps = new(GoDeps) repo.GoPrimitive = false - ok, err := repo.isPrimativeGoMod() + ok, err := repo.IsPrimitive() if err != nil { // this means this repo does not depend on any other package log.Info("PRIMATIVE repo error:", repo.GoPath, "err =", err) @@ -121,7 +121,6 @@ func (repo *Repo) PublishedLen() int { // returns true if the last published func (all *Repos) GoDepsChanged(repo *Repo) (bool, error) { var upgrade bool = false - if repo.GoDeps == nil { repo.RedoGoMod() } diff --git a/isPrimitive.go b/isPrimitive.go new file mode 100644 index 0000000..6579013 --- /dev/null +++ b/isPrimitive.go @@ -0,0 +1,48 @@ +package gitpb + +// only reads in the go.mod file. doesn't change anything + +import ( + "bufio" + "errors" + "os" + "path/filepath" + "strings" + + "go.wit.com/log" +) + +// Detect a 'Primative' package. Sets the isPrimative 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) IsPrimitive() (bool, error) { + // go mod init & go mod tidy ran without errors + log.Log(GITPB, "isPrimativeGoMod()", repo.FullPath) + tmp := filepath.Join(repo.FullPath, "go.mod") + gomod, err := os.Open(tmp) + if err != nil { + log.Log(GITPB, "missing go.mod", repo.FullPath) + return false, err + } + defer gomod.Close() + + scanner := bufio.NewScanner(gomod) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + + parts := strings.Split(line, " ") + log.Log(GITPB, " gomod:", parts) + if len(parts) >= 1 { + 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") + } + + } + } + repo.GoPrimitive = true + repo.GoDeps = nil + return true, nil +} diff --git a/shell.go b/shell.go index 18aef05..ae741e3 100644 --- a/shell.go +++ b/shell.go @@ -60,6 +60,7 @@ func (repo *Repo) Exists(filename string) bool { testf := filepath.Join(repo.FullPath, filename) _, err := os.Stat(testf) if err != nil { + log.Warn("gitpb: Exists() failed for", testf) return false } return true -- cgit v1.2.3