From 340872788e76776574be3ba292e1f7a43cc41a8f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 15 Dec 2024 08:48:06 -0600 Subject: [PATCH] clone() and misc other fixes and improvements --- Makefile | 6 ------ repoClone.go => clone.go | 4 ++++ gitCheckout.go | 2 +- goSrcScan.go | 1 + goWork.go | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) rename repoClone.go => clone.go (98%) diff --git a/Makefile b/Makefile index d65515c..e754bad 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,6 @@ vet: goimports: goimports -w *.go -redomod: - rm -f go.* - GO111MODULE= go mod init - GO111MODULE= go mod tidy - go mod edit -go=1.20 - clean: rm -f *.pb.go -rm -f go.* diff --git a/repoClone.go b/clone.go similarity index 98% rename from repoClone.go rename to clone.go index ab1acee..514624f 100644 --- a/repoClone.go +++ b/clone.go @@ -81,6 +81,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) { // try a direct git clone against the gopath // cloneActual("helloworld", "/home/jcarr/go/src/go.wit.com/apps", "https://go.wit.com/apps/helloworld") if finalurl, err := cloneActual(dirname, basedir, url); err == nil { + f.Repos.DeleteByGoPath(gopath) // git clone worked! return f.Repos.NewGoPath(f.goSrc, gopath, finalurl) } @@ -94,6 +95,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) { log.Info("findGoImport() DID NOT WORK", err) } else { if finalurl, err := cloneActual(dirname, basedir, url); err == nil { + f.Repos.DeleteByGoPath(gopath) // git clone worked! return f.Repos.NewGoPath(f.goSrc, gopath, finalurl) } @@ -106,6 +108,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) { log.Info("go list failed", err) } else { if finalurl, err := cloneActual(dirname, basedir, url); err == nil { + f.Repos.DeleteByGoPath(gopath) // git clone worked! return f.Repos.NewGoPath(f.goSrc, gopath, finalurl) } @@ -115,6 +118,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) { // try to parse a redirect if finalurl, err := clonePathHack(dirname, basedir, gopath); err == nil { + f.Repos.DeleteByGoPath(gopath) // WTF didn't go-import or go list work? return f.Repos.NewGoPath(f.goSrc, gopath, finalurl) } diff --git a/gitCheckout.go b/gitCheckout.go index b0ccc18..2952ccf 100644 --- a/gitCheckout.go +++ b/gitCheckout.go @@ -133,7 +133,7 @@ func (f *Forge) CheckoutMaster() bool { } func (f *Forge) CheckoutUser() bool { - log.Log(FORGEPBWARN, "running git checkout master everwhere") + log.Log(FORGEPBWARN, "running git checkout user everwhere") var failed int = 0 var count int = 0 all := f.Repos.SortByGoPath() diff --git a/goSrcScan.go b/goSrcScan.go index c13dce3..a50dbb2 100644 --- a/goSrcScan.go +++ b/goSrcScan.go @@ -65,6 +65,7 @@ func gitDirectoriesNew(srcDir string) ([]string, error) { switch fname { case "repos.pb": case "go.work": + case "go.work.last": default: // todo: figure out a way to do padding for init() log.Info("WARNING: you have an untracked file outside of any .git repository:", path) diff --git a/goWork.go b/goWork.go index afb09da..f8f75d8 100644 --- a/goWork.go +++ b/goWork.go @@ -23,7 +23,7 @@ func (f *Forge) MakeGoWork() error { } defer workf.Close() - fmt.Fprintln(workf, "go 1.20") // fix this + fmt.Fprintln(workf, "go 1.21") // fix this fmt.Fprintln(workf, "") fmt.Fprintln(workf, "use (")