stop using GoSrc()
This commit is contained in:
parent
6c3162f7ce
commit
eda91e3af6
8
build.go
8
build.go
|
@ -129,9 +129,9 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
||||||
|
|
||||||
testenv := os.Getenv("GO111MODULE")
|
testenv := os.Getenv("GO111MODULE")
|
||||||
if testenv == "off" {
|
if testenv == "off" {
|
||||||
log.Info("GO111MODULE=off", "f.goWork =", f.IsGoWork(), "f.gosrc =", f.GetGoSrc())
|
log.Info("GO111MODULE=off", "f.goWork =", f.IsGoWork())
|
||||||
} else {
|
} 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:", repo.FullPath)
|
||||||
log.Info("running:", cmd)
|
log.Info("running:", cmd)
|
||||||
|
@ -202,10 +202,10 @@ func (f *Forge) runAutogenpb(repo *gitpb.Repo) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sortcut to find
|
// used by guireleaser for now
|
||||||
func (f *Forge) FindWorkingDirRepo() *gitpb.Repo {
|
func (f *Forge) FindWorkingDirRepo() *gitpb.Repo {
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
basedir := strings.TrimPrefix(pwd, f.GetGoSrc())
|
basedir := strings.TrimPrefix(pwd, f.Config.ReposDir)
|
||||||
basedir = strings.Trim(basedir, "/")
|
basedir = strings.Trim(basedir, "/")
|
||||||
return f.FindByGoPath(basedir)
|
return f.FindByGoPath(basedir)
|
||||||
}
|
}
|
||||||
|
|
4
clone.go
4
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
|
// 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"
|
// 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 {
|
if pb := f.FindAnyPath(fullpath); pb != nil {
|
||||||
// repo already exists
|
// repo already exists
|
||||||
return pb, nil
|
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) {
|
func (f *Forge) urlClone(gopath, giturl string) (*gitpb.Repo, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
fullpath := filepath.Join(f.goSrc, gopath)
|
fullpath := filepath.Join(f.Config.ReposDir, gopath)
|
||||||
basedir, newdir := filepath.Split(fullpath)
|
basedir, newdir := filepath.Split(fullpath)
|
||||||
|
|
||||||
// clone the URL directly
|
// clone the URL directly
|
||||||
|
|
|
@ -8,14 +8,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Forge) GetHome() string {
|
func (f *Forge) GetHome() string {
|
||||||
return f.goSrc
|
return f.Config.ReposDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// look for a go.work file
|
// look for a go.work file
|
||||||
// otherwise use ~/go/src
|
// otherwise use ~/go/src
|
||||||
func (f *Forge) findGoSrc() (string, error) {
|
func (f *Forge) findGoSrc() (string, error) {
|
||||||
|
@ -57,7 +56,7 @@ func useGoSrc() (string, error) {
|
||||||
|
|
||||||
func (f *Forge) goWorkExists() bool {
|
func (f *Forge) goWorkExists() bool {
|
||||||
var err error
|
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 {
|
if _, err = os.Stat(workFilePath); err == nil {
|
||||||
// log.Info("f.goWorkExists() found", workFilePath)
|
// log.Info("f.goWorkExists() found", workFilePath)
|
||||||
return true
|
return true
|
||||||
|
@ -69,6 +68,7 @@ func (f *Forge) goWorkExists() bool {
|
||||||
// log.Info("f.goWorkExists() os.Stat() error", err, workFilePath)
|
// log.Info("f.goWorkExists() os.Stat() error", err, workFilePath)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func digup(path string) (string, error) {
|
func digup(path string) (string, error) {
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -22,7 +22,7 @@ func reloadCheck(repo *gitpb.Repo) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) ScanGoSrc() (bool, error) {
|
func (f *Forge) ScanGoSrc() (bool, error) {
|
||||||
dirs, err := gitDirectoriesNew(f.goSrc)
|
dirs, err := gitDirectoriesNew(f.Config.ReposDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ func (f *Forge) ScanGoSrc() (bool, error) {
|
||||||
var gopaths []string
|
var gopaths []string
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
// log.Info("forge.ScanGoSrc()", dir)
|
// log.Info("forge.ScanGoSrc()", dir)
|
||||||
if strings.HasPrefix(dir, f.goSrc) {
|
if strings.HasPrefix(dir, f.Config.ReposDir) {
|
||||||
gopath := strings.TrimPrefix(dir, f.goSrc)
|
gopath := strings.TrimPrefix(dir, f.Config.ReposDir)
|
||||||
gopath = strings.Trim(gopath, "/")
|
gopath = strings.Trim(gopath, "/")
|
||||||
if r := f.FindByGoPath(gopath); r != nil {
|
if r := f.FindByGoPath(gopath); r != nil {
|
||||||
// log.Info("already have", gopath)
|
// 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) {
|
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)
|
log.Info("forge creating protobuf for", fullpath)
|
||||||
repo, err := f.NewGoRepo(gopath, "")
|
repo, err := f.NewGoRepo(gopath, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
18
goWork.go
18
goWork.go
|
@ -18,7 +18,7 @@ func (f *Forge) MakeGoWork() error {
|
||||||
// has gone terribly wrong
|
// has gone terribly wrong
|
||||||
return errors.New("if you want a go.work file in ~/go/src/, touch it first")
|
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)
|
workf, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -32,26 +32,10 @@ func (f *Forge) MakeGoWork() error {
|
||||||
all := f.Repos.SortByFullPath()
|
all := f.Repos.SortByFullPath()
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
repo := all.Next()
|
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() == "" {
|
if repo.GetGoPath() == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Fprintln(workf, "\t"+repo.GetGoPath())
|
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, ")")
|
fmt.Fprintln(workf, ")")
|
||||||
return nil
|
return nil
|
||||||
|
|
4
init.go
4
init.go
|
@ -106,7 +106,7 @@ func (f *Forge) setenv() {
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
// f.configDir = os.Getenv("FORGE_CONFIG")
|
// 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.forgeURL = os.Getenv("FORGE_URL")
|
||||||
f.hostname = os.Getenv("HOSTNAME")
|
f.hostname = os.Getenv("HOSTNAME")
|
||||||
if os.Getenv("FORGE_GOWORK") == "true" {
|
if os.Getenv("FORGE_GOWORK") == "true" {
|
||||||
|
@ -190,7 +190,7 @@ func (f *Forge) configENV() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// f.configDir = os.Getenv("FORGE_CONFIG")
|
// 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.forgeURL = os.Getenv("FORGE_URL")
|
||||||
f.Config.ForgeURL = os.Getenv("FORGE_URL")
|
f.Config.ForgeURL = os.Getenv("FORGE_URL")
|
||||||
// f.patchDir = os.Getenv("FORGE_PATCHDIR")
|
// f.patchDir = os.Getenv("FORGE_PATCHDIR")
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
|
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)
|
test := f.Repos.FindByFullPath(fullpath)
|
||||||
if test != nil {
|
if test != nil {
|
||||||
return 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 {
|
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)
|
return f.Repos.FindByFullPath(fullpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +242,6 @@ func (f *Forge) FindAnyPath(dir string) *gitpb.Repo {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) DeleteByGoPath(gopath string) bool {
|
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)
|
return f.Repos.DeleteByFullPath(fullpath)
|
||||||
}
|
}
|
||||||
|
|
11
structs.go
11
structs.go
|
@ -10,25 +10,20 @@ import (
|
||||||
type Forge struct {
|
type Forge struct {
|
||||||
// one-time initialized data
|
// one-time initialized data
|
||||||
once sync.Once
|
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
|
Config *ForgeConfigs // config repos for readonly, private, etc
|
||||||
Repos *gitpb.Repos // the repo protobufs
|
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
|
configSave bool // if you need to save the config because things changed
|
||||||
hostname string // your hostname
|
hostname string // your hostname
|
||||||
rillX int // used for Rill()
|
rillX int // used for Rill()
|
||||||
rillY int // used for Rill()
|
rillY int // used for Rill()
|
||||||
Patchsets *Patchsets // patches that are in progress
|
goWork bool // means the user is currently using a go.work file
|
||||||
goSrc string // the path to go/src
|
// goSrc string // the path to go/src
|
||||||
// forgeURL string // URL to use to forge.wit.com
|
// forgeURL string // URL to use to forge.wit.com
|
||||||
// configDir string // normally ~/.config/forge
|
// configDir string // normally ~/.config/forge
|
||||||
// patchDir string // where patches are stored
|
// patchDir string // where patches are stored
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) GetGoSrc() string {
|
|
||||||
return f.goSrc
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *Forge) IsGoWork() bool {
|
func (f *Forge) IsGoWork() bool {
|
||||||
return f.goWork
|
return f.goWork
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue