From a31f675e1228907786e90ffd0235eb10c42cd833 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 15 Dec 2024 15:52:46 -0600 Subject: [PATCH] still trying to perfect this. todo: make gitpb perfect --- clone.go | 14 ++++++++++++++ finalGoSumCheck.go | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/clone.go b/clone.go index 3d308a7..7fb8a2a 100644 --- a/clone.go +++ b/clone.go @@ -133,6 +133,20 @@ func (f *Forge) finishClone(gopath string, giturl string) (*gitpb.Repo, error) { log.Warn("forge.Clone() url changed", newr.URL, "to", giturl) newr.URL = giturl } + if err := newr.RepoIgnoresGoMod(); err != nil { + log.Info("never modify go.mod or go.sum for this repo", newr.GoPath) + log.Info("We recommend you add 'go.*' to your .gitignore file and store those files as git tag metadata") + newr.ParseGoSum() + return newr, nil + } + + if newr.Exists("go.mod") { + return newr, nil + } + + log.Info("todo: something went wrong probably. didn't finish. run go-mod-clean? (can't here. loop of circles)") + log.Info("todo: do go mod init here directly") + log.Info("todo: try to run go mod init here", newr.GoPath) return newr, nil } diff --git a/finalGoSumCheck.go b/finalGoSumCheck.go index 01a9195..bb2df87 100644 --- a/finalGoSumCheck.go +++ b/finalGoSumCheck.go @@ -27,13 +27,16 @@ func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool { return false } - // clear out the protobuf and rescan from the file - check.GoDeps = nil - if ok, _ := check.IsPrimitive(); ok { + // IsPrimitive() is expected to set GoPrimitive = true in the protobuf + if err := check.SetPrimitive(); err == nil { + log.Info("gitpb.SetPrimitive() returned true for", check.GoPath) return true } + + // clear out the protobuf and rescan from the file + check.GoDeps = nil if ok, err := check.ParseGoSum(); !ok { - log.Info("FinalGoDepsCheckOk() error", err) + log.Info("forge.FinalGoDepsCheckOk() error", err) return false }