experiement with ~/.cache/forge/
This commit is contained in:
parent
25cee2b013
commit
554adc9f0f
|
@ -46,10 +46,13 @@ func (f *Forge) ScanGoSrc() (bool, error) {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns a repo protobuf for a directory if the directory is a git repo
|
||||||
func (f *Forge) ScanDir(dir string) *gitpb.Repo {
|
func (f *Forge) ScanDir(dir string) *gitpb.Repo {
|
||||||
// repo, err := f.NewGoRepo(gopath, "")
|
repo, err := f.Repos.NewRepo(dir, "")
|
||||||
repo, err := f.Repos.NewGoRepo(dir, "")
|
if err != nil {
|
||||||
log.Info("need to implement ScanDir()", dir, err)
|
log.Info("ScanDir() error", dir, err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
49
init.go
49
init.go
|
@ -180,3 +180,52 @@ func (f *Forge) Exit() {
|
||||||
// log.Info("forge.Exit() ok")
|
// log.Info("forge.Exit() ok")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RawInitPB() *Forge {
|
||||||
|
f := new(Forge)
|
||||||
|
|
||||||
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
// todo: check or exit if err?
|
||||||
|
|
||||||
|
// TODO: rethink this but it works for now
|
||||||
|
if os.Getenv("FORGE_GOSRC") == "" {
|
||||||
|
fullpath := filepath.Join(homeDir, ".cache/forge")
|
||||||
|
err := os.MkdirAll(fullpath, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
log.Log(WARN, "mkdir failed", fullpath, err)
|
||||||
|
}
|
||||||
|
os.Setenv("FORGE_GOSRC", fullpath)
|
||||||
|
}
|
||||||
|
f.goSrc = os.Getenv("FORGE_GOSRC")
|
||||||
|
|
||||||
|
// also rethink this, but maybe this is the right thing to do
|
||||||
|
if os.Getenv("FORGE_CONFIG") == "" {
|
||||||
|
fullpath := filepath.Join(homeDir, ".config/forge")
|
||||||
|
os.MkdirAll(fullpath, os.ModePerm)
|
||||||
|
os.Setenv("FORGE_CONFIG", fullpath)
|
||||||
|
}
|
||||||
|
|
||||||
|
f.configDir = os.Getenv("FORGE_CONFIG")
|
||||||
|
|
||||||
|
// load the ~/.config/forge/ config
|
||||||
|
f.Config = new(ForgeConfigs)
|
||||||
|
if err := f.Config.ConfigLoad(); err != nil {
|
||||||
|
log.Log(WARN, "forgepb.ConfigLoad() failed", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
f.Repos = gitpb.NewRepos()
|
||||||
|
f.Repos.ConfigLoad()
|
||||||
|
|
||||||
|
f.forgeURL = "https://forge.wit.com/"
|
||||||
|
|
||||||
|
if os.Getenv("FORGE_URL") != "" {
|
||||||
|
f.forgeURL = os.Getenv("FORGE_URL")
|
||||||
|
log.Info("got forge url", f.forgeURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: play with these / determine good values based on user's machine
|
||||||
|
f.rillX = 10
|
||||||
|
f.rillY = 20
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue