diff options
Diffstat (limited to 'init.go')
| -rw-r--r-- | init.go | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -3,6 +3,7 @@ package forgepb import ( + "errors" "os" "os/user" "path/filepath" @@ -73,8 +74,7 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { // always define if ENV.Get("gopath") == "" { gopath := filepath.Join(ENV.Get("homedir"), "go/src") - ENV.Set("gopath", gopath) - ENV.Save() + ENV.SetGlobal("lib/forgepb", "gopath", gopath) } // always set f.mode @@ -91,18 +91,16 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { // todo: play with these / determine good values based on user's machine if cobol.Int(ENV.Get("RillX")) == 0 { - ENV.Set("RillX", "10") - ENV.Save() + ENV.SetGlobal("lib/forgepb", "RillX", "10") } if cobol.Int(ENV.Get("RillY")) == 0 { - ENV.Set("RillY", "20") + ENV.SetGlobal("lib/forgepb", "RillY", "20") ENV.Save() } // create an initial repos.pb file // panic() here? // warning? // (probably not. it's just the repos.pb cache file - f.Repos = gitpb.NewRepos() - err := f.Repos.CacheLoad() // loads the file from ~/.cache/forge/repos.pb + err := f.reposCacheLoad() // loads the file from ~/.cache/forge/repos.pb if err == nil { log.Printf("forge loaded %s file with len(%d) repos\n", f.Repos.Filename, f.Repos.Len()) } else { @@ -112,6 +110,16 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { return f } +func (f *Forge) reposCacheLoad() error { + if f.Repos != nil { + return errors.New("already loaded") + } + f.Repos = gitpb.NewRepos() + err := config.LoadAppnameCache(f.Repos, "forge") + ENV.SetGlobal("lib/forgepb", "ReposPB", f.Repos.Filename) + return err +} + func (f *Forge) SetConfigSave(b bool) { config.SetChanged("forge", b) } |
