summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-03-09 09:23:04 -0600
committerJeff Carr <[email protected]>2024-03-09 09:23:04 -0600
commite6be71a33caf7dba9d4060231bd34586aeb41fe2 (patch)
tree39c754a4147ea29b715b0c79cfdc697e387f9a6f /main.go
parent581a4d96fcdcaf93a3c3169ecc60c2f603ceb7ae (diff)
git clone deps
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 28 insertions, 8 deletions
diff --git a/main.go b/main.go
index a37f07f..fb1f6b6 100644
--- a/main.go
+++ b/main.go
@@ -4,10 +4,12 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
"go.wit.com/lib/gui/repolist"
+ "go.wit.com/lib/gui/repostatus"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@@ -51,10 +53,23 @@ func main() {
newr.Status.MakeRedomod()
// rv.NewRepo("go.wit.com/apps/helloworld")
+ for _, path := range repostatus.ScanGitDirectories(wdir) {
+ gopath := strings.TrimPrefix(path, wdir)
+ gopath = strings.Trim(gopath, "/")
+ // log.Info("Also should add:", gopath)
+ rv.NewRepo(gopath)
+ }
+
+ godep := newr.Status.GetGoDeps()
+ for gopath, version := range godep {
+ log.Info("git clone =", gopath, version)
+ rv.NewRepo(gopath)
+ }
for _, repo := range rv.AllRepos() {
log.Info("found repo", repo.GoPath(), repo.Status.Path())
}
+ rv.MakeGoWork()
// rv.Watchdog(func() {
// log.Info("watchdog")
@@ -76,26 +91,31 @@ func findWorkFile() (string, error) {
pwd, err := os.Getwd()
if err == nil {
// Check for go.work in the current directory and then move up until root
- pwd, err = digup(pwd)
- if err == nil {
+ if pwd, err := digup(pwd); err == nil {
+ // found an existing go.work file
os.Chdir(pwd)
return pwd, nil
}
+ // if the user added '--work' on the cmdline, make a work directory and init the go.work file
if myargs.Work {
- pwd := filepath.Join(pwd, "work")
- shell.Mkdir(pwd)
- os.Chdir(pwd)
+ pwd, err = os.Getwd()
+ newpwd := filepath.Join(pwd, "work")
+ shell.Mkdir(newpwd)
+ os.Chdir(newpwd)
if _, err := os.Stat("go.work"); err == nil {
- return pwd, nil
+ return newpwd, nil
}
- shell.RunPath(pwd, []string{"go", "work", "init"})
+ shell.RunPath(newpwd, []string{"go", "work", "init"})
if shell.Exists("go.work") {
- return pwd, nil
+ return newpwd, nil
}
}
}
+ // there are no go.work files, resume the ~/go/src behavior from prior to golang 1.22
+ // this is the 'old way" and works fine for me. I use it because I like the ~/go/src directory
+ // because I know exactly what is in it: GO stuff & nothing else
homeDir, err := os.UserHomeDir()
if err != nil {
return "", err