diff --git a/build.go b/build.go index 58fe7ad..fa04557 100644 --- a/build.go +++ b/build.go @@ -129,9 +129,9 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err testenv := os.Getenv("GO111MODULE") if testenv == "off" { - log.Info("GO111MODULE=off", "f.goWork =", f.IsGoWork(), "f.gosrc =", f.GetGoSrc()) + log.Info("GO111MODULE=off", "f.goWork =", f.IsGoWork()) } else { - log.Info("GO111MODULE=", testenv, "f.goWork =", f.IsGoWork(), "f.gosrc =", f.GetGoSrc()) + log.Info("GO111MODULE=", testenv, "f.goWork =", f.IsGoWork()) } log.Info("running:", repo.FullPath) log.Info("running:", cmd) @@ -202,10 +202,10 @@ func (f *Forge) runAutogenpb(repo *gitpb.Repo) error { return nil } -// sortcut to find +// used by guireleaser for now func (f *Forge) FindWorkingDirRepo() *gitpb.Repo { pwd, _ := os.Getwd() - basedir := strings.TrimPrefix(pwd, f.GetGoSrc()) + basedir := strings.TrimPrefix(pwd, f.Config.ReposDir) basedir = strings.Trim(basedir, "/") return f.FindByGoPath(basedir) } diff --git a/clone.go b/clone.go index 04facf2..0039296 100644 --- a/clone.go +++ b/clone.go @@ -29,7 +29,7 @@ func (f *Forge) GoClone(gopath string) (*gitpb.Repo, error) { // will match /root/go/src/go.wit.com/apps/go-clone/something/inside // and return the *gitpb.Repo for "go.wit.com/apps/go-clone" - fullpath := filepath.Join(f.goSrc, gopath) + fullpath := filepath.Join(f.Config.ReposDir, gopath) if pb := f.FindAnyPath(fullpath); pb != nil { // repo already exists return pb, nil @@ -156,7 +156,7 @@ func (f *Forge) goClonePop(gopath string) (*gitpb.Repo, error) { func (f *Forge) urlClone(gopath, giturl string) (*gitpb.Repo, error) { var err error - fullpath := filepath.Join(f.goSrc, gopath) + fullpath := filepath.Join(f.Config.ReposDir, gopath) basedir, newdir := filepath.Split(fullpath) // clone the URL directly diff --git a/goSrcFind.go b/goSrcFind.go index 938ebe5..02b7659 100644 --- a/goSrcFind.go +++ b/goSrcFind.go @@ -8,14 +8,13 @@ import ( "fmt" "os" "path/filepath" - - "go.wit.com/log" ) func (f *Forge) GetHome() string { - return f.goSrc + return f.Config.ReposDir } +/* // look for a go.work file // otherwise use ~/go/src func (f *Forge) findGoSrc() (string, error) { @@ -57,7 +56,7 @@ func useGoSrc() (string, error) { func (f *Forge) goWorkExists() bool { var err error - workFilePath := filepath.Join(f.GetGoSrc(), "go.work") + workFilePath := filepath.Join(f.Config.ReposDir, "go.work") if _, err = os.Stat(workFilePath); err == nil { // log.Info("f.goWorkExists() found", workFilePath) return true @@ -69,6 +68,7 @@ func (f *Forge) goWorkExists() bool { // log.Info("f.goWorkExists() os.Stat() error", err, workFilePath) return false } +*/ func digup(path string) (string, error) { for { diff --git a/goSrcScan.go b/goSrcScan.go index f80742f..1f07862 100644 --- a/goSrcScan.go +++ b/goSrcScan.go @@ -22,7 +22,7 @@ func reloadCheck(repo *gitpb.Repo) error { } func (f *Forge) ScanGoSrc() (bool, error) { - dirs, err := gitDirectoriesNew(f.goSrc) + dirs, err := gitDirectoriesNew(f.Config.ReposDir) if err != nil { return false, err } @@ -44,8 +44,8 @@ func (f *Forge) ScanGoSrc() (bool, error) { var gopaths []string for _, dir := range dirs { // log.Info("forge.ScanGoSrc()", dir) - if strings.HasPrefix(dir, f.goSrc) { - gopath := strings.TrimPrefix(dir, f.goSrc) + if strings.HasPrefix(dir, f.Config.ReposDir) { + gopath := strings.TrimPrefix(dir, f.Config.ReposDir) gopath = strings.Trim(gopath, "/") if r := f.FindByGoPath(gopath); r != nil { // log.Info("already have", gopath) @@ -193,7 +193,7 @@ func (f *Forge) rillScanDirs(gopaths []string) (int, error) { } func (f *Forge) checkpath(gopath string, url string) (*gitpb.Repo, error) { - fullpath := filepath.Join(f.GetGoSrc(), gopath) + fullpath := filepath.Join(f.Config.ReposDir, gopath) log.Info("forge creating protobuf for", fullpath) repo, err := f.NewGoRepo(gopath, "") if err != nil { diff --git a/goWork.go b/goWork.go index 9446427..7a783cb 100644 --- a/goWork.go +++ b/goWork.go @@ -18,7 +18,7 @@ func (f *Forge) MakeGoWork() error { // has gone terribly wrong return errors.New("if you want a go.work file in ~/go/src/, touch it first") } - filename := filepath.Join(f.GetGoSrc(), "go.work") + filename := filepath.Join(f.Config.ReposDir, "go.work") workf, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { return err @@ -32,26 +32,10 @@ func (f *Forge) MakeGoWork() error { all := f.Repos.SortByFullPath() for all.Scan() { repo := all.Next() - /* - if !repo.IsGoLang() == "" { - // skip repos that aren't go - // todo: handle non-flat repos? - log.Info("skip non-go", repo.GetGoPath) - continue - } - */ if repo.GetGoPath() == "" { continue } fmt.Fprintln(workf, "\t"+repo.GetGoPath()) - /* - if repo.pb.Exists("go.mod") { - // log.Info("ADDING REPO", goSrcDir, repo.GetGoPath()) - } else { - fmt.Fprintln(workf, "\t"+repo.GetGoPath) - log.Log(REPO, "missing go.mod for", repo.GetGoPath()) - } - */ } fmt.Fprintln(workf, ")") return nil diff --git a/init.go b/init.go index fbb6210..4c8950e 100644 --- a/init.go +++ b/init.go @@ -106,7 +106,7 @@ func (f *Forge) setenv() { os.Exit(-1) } // f.configDir = os.Getenv("FORGE_CONFIG") - f.goSrc = os.Getenv("FORGE_GOSRC") + // f.goSrc = os.Getenv("FORGE_GOSRC") // f.forgeURL = os.Getenv("FORGE_URL") f.hostname = os.Getenv("HOSTNAME") if os.Getenv("FORGE_GOWORK") == "true" { @@ -190,7 +190,7 @@ func (f *Forge) configENV() bool { } // f.configDir = os.Getenv("FORGE_CONFIG") - f.goSrc = os.Getenv("FORGE_GOSRC") + // f.goSrc = os.Getenv("FORGE_GOSRC") // f.forgeURL = os.Getenv("FORGE_URL") f.Config.ForgeURL = os.Getenv("FORGE_URL") // f.patchDir = os.Getenv("FORGE_PATCHDIR") diff --git a/repoNew.go b/repoNew.go index 15f4d9d..3a80511 100644 --- a/repoNew.go +++ b/repoNew.go @@ -14,7 +14,7 @@ import ( ) func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) { - fullpath := filepath.Join(f.GetGoSrc(), gopath) + fullpath := filepath.Join(f.Config.ReposDir, gopath) test := f.Repos.FindByFullPath(fullpath) if test != nil { return test, nil @@ -215,7 +215,7 @@ func (f *Forge) AddFullPath(fulldir string) *gitpb.Repo { } func (f *Forge) FindByGoPath(gopath string) *gitpb.Repo { - fullpath := filepath.Join(f.GetGoSrc(), gopath) + fullpath := filepath.Join(f.Config.ReposDir, gopath) return f.Repos.FindByFullPath(fullpath) } @@ -242,6 +242,6 @@ func (f *Forge) FindAnyPath(dir string) *gitpb.Repo { } func (f *Forge) DeleteByGoPath(gopath string) bool { - fullpath := filepath.Join(f.GetGoSrc(), gopath) + fullpath := filepath.Join(f.Config.ReposDir, gopath) return f.Repos.DeleteByFullPath(fullpath) } diff --git a/structs.go b/structs.go index 76aa7c7..08aa464 100644 --- a/structs.go +++ b/structs.go @@ -10,25 +10,20 @@ import ( type Forge struct { // one-time initialized data once sync.Once - initErr error // init error, if any - goWork bool // means the user is currently using a go.work file Config *ForgeConfigs // config repos for readonly, private, etc Repos *gitpb.Repos // the repo protobufs + Patchsets *Patchsets // patches that are in progress configSave bool // if you need to save the config because things changed hostname string // your hostname rillX int // used for Rill() rillY int // used for Rill() - Patchsets *Patchsets // patches that are in progress - goSrc string // the path to go/src + goWork bool // means the user is currently using a go.work file + // goSrc string // the path to go/src // forgeURL string // URL to use to forge.wit.com // configDir string // normally ~/.config/forge // patchDir string // where patches are stored } -func (f *Forge) GetGoSrc() string { - return f.goSrc -} - func (f *Forge) IsGoWork() bool { return f.goWork }