clean up Init()
This commit is contained in:
parent
4e94089128
commit
9873bc3d57
|
@ -51,7 +51,6 @@ func (f *Forge) ScanGoSrc() (bool, error) {
|
|||
func gitDirectoriesNew(srcDir string) ([]string, error) {
|
||||
var all []string
|
||||
var trip bool
|
||||
reposfile := filepath.Join(srcDir, "repos.pb")
|
||||
err := filepath.WalkDir(srcDir, func(path string, d os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
// Handle possible errors, like permission issues
|
||||
|
@ -62,9 +61,11 @@ func gitDirectoriesNew(srcDir string) ([]string, error) {
|
|||
if d.IsDir() {
|
||||
// log.Info("path is dir", path)
|
||||
} else {
|
||||
if path == reposfile {
|
||||
// ignore repos.pb // todo: also ignore go.work // add config option to not warn about this
|
||||
} else {
|
||||
_, fname := filepath.Split(path)
|
||||
switch fname {
|
||||
case "repos.pb":
|
||||
case "go.work":
|
||||
default:
|
||||
// todo: figure out a way to do padding for init()
|
||||
log.Info("WARNING: you have an untracked file outside of any .git repository:", path)
|
||||
trip = true
|
||||
|
|
36
init.go
36
init.go
|
@ -9,6 +9,9 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// todo: use initOnce
|
||||
// cache.go has Do()
|
||||
// f.initOnce.Do(f.initWork)
|
||||
func Init() *Forge {
|
||||
f := new(Forge)
|
||||
|
||||
|
@ -37,22 +40,32 @@ func Init() *Forge {
|
|||
}
|
||||
|
||||
// print out the settings that will be used
|
||||
log.Info("forgepbb.Init() FORGE_CONFIG", os.Getenv("FORGE_CONFIG"))
|
||||
log.Info("forgepbb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "f.goWork =", f.IsGoWork())
|
||||
|
||||
// cache.go has Do()
|
||||
// f.initOnce.Do(f.initWork)
|
||||
|
||||
f.Config = new(ForgeConfigs)
|
||||
log.Info("forgepb.Init() FORGE_CONFIG", os.Getenv("FORGE_CONFIG"))
|
||||
|
||||
// load the ~/.config/forge/ config
|
||||
f.Config = new(ForgeConfigs)
|
||||
if err := f.Config.ConfigLoad(); err != nil {
|
||||
log.Warn("forgepb.ConfigLoad() failed", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
if f.IsGoWork() {
|
||||
log.Info("forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = true)")
|
||||
} else {
|
||||
log.Info("forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = false)")
|
||||
}
|
||||
f.Repos = new(gitpb.Repos)
|
||||
f.Repos.ConfigLoad()
|
||||
|
||||
start := f.Repos.Len()
|
||||
f.ScanGoSrc()
|
||||
end := f.Repos.Len()
|
||||
if (end - start) == 0 {
|
||||
log.Info("forgepb.Scan() Scan did not find new git repositories.")
|
||||
} else {
|
||||
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories.")
|
||||
}
|
||||
|
||||
f.Machine = new(zoopb.Machine)
|
||||
|
||||
if err := f.Machine.ConfigLoad(); err != nil {
|
||||
|
@ -60,14 +73,5 @@ func Init() *Forge {
|
|||
os.Exit(-1)
|
||||
}
|
||||
f.Machine.InitWit()
|
||||
|
||||
start := f.Repos.Len()
|
||||
f.ScanGoSrc()
|
||||
end := f.Repos.Len()
|
||||
if (end - start) == 0 {
|
||||
log.Info("Scan of", f.GetGoSrc(), "did not find new git repositories")
|
||||
} else {
|
||||
log.Info("Scan of", f.GetGoSrc(), "Found", end-start, "new git repositories")
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue