git clone deps
This commit is contained in:
parent
581a4d96fc
commit
e6be71a33c
36
main.go
36
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
|
||||
|
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
|
@ -15,8 +16,9 @@ func addDir(d string) {
|
|||
}
|
||||
}
|
||||
|
||||
func readControlFile() error {
|
||||
file, err := os.Open("go.work")
|
||||
func readControlFile(path string) error {
|
||||
fullname := filepath.Join(path, "go.work")
|
||||
file, err := os.Open(fullname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue