From 4dbfd68272d1753562fd25e384148bcdf47f6218 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 9 Mar 2024 09:23:41 -0600 Subject: [PATCH] pull down missing go deps --- common.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/common.go b/common.go index c41970d..075b026 100644 --- a/common.go +++ b/common.go @@ -1,6 +1,10 @@ package repolist import ( + "fmt" + "os" + "path/filepath" + "go.wit.com/gui" "go.wit.com/lib/gui/repostatus" "go.wit.com/log" @@ -172,3 +176,34 @@ func (rl *RepoList) TotalGo() int { } return count } + +// very much a hack job +func (rl *RepoList) MakeGoWork() error { + goSrcDir := os.Getenv("REPO_WORK_PATH") + filename := filepath.Join(goSrcDir, "go.work") + + f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600) + if err != nil { + return err + } + defer f.Close() + + fmt.Fprintln(f, "go 1.21.4") // fix this + fmt.Fprintln(f, "") + fmt.Fprintln(f, "use (") + for _, repo := range rl.allrepos { + if repo.Status.GoPath() == "" { + // skip repos that aren't go + // todo: handle non-flat repos? + continue + } + if repo.Status.Exists("go.mod") { + fmt.Fprintln(f, "\t"+repo.Status.GoPath()) + } else { + log.Info("missing go.mod for", repo.Status.Path()) + repo.Status.MakeRedomod() + } + } + fmt.Fprintln(f, ")") + return nil +}