diff options
| -rw-r--r-- | config.go | 18 | ||||
| -rw-r--r-- | forgeConfig.Common.go (renamed from config.common.go) | 0 | ||||
| -rw-r--r-- | init.go | 29 | ||||
| -rw-r--r-- | run.go | 2 |
4 files changed, 30 insertions, 19 deletions
@@ -135,14 +135,16 @@ func loadStdConfig() *ForgeConfigs { homeDir, _ := os.UserHomeDir() cfgdir := filepath.Join(homeDir, ".config/forge") - os.MkdirAll(cfgdir, os.ModePerm) - cfg.HomeDir = cfgdir - cfg.ReposDir = filepath.Join(homeDir, "go/src") // todo: check working directory + os.MkdirAll(cfgdir, 0755) + cfg.ReposPB = filepath.Join(cfgdir, "repos.pb") cfg.PatchPB = filepath.Join(cfgdir, "patches.pb") cfg.ForgeURL = "http://forge.wit.com/" + cfg.ReposDir = filepath.Join(homeDir, "go/src") // todo: check working directory + os.MkdirAll(cfg.ReposDir, 0755) + cfg.addSampleConfigs() cfg.DumpENV() config.SetChanged("forge", true) @@ -153,6 +155,9 @@ func loadStdConfig() *ForgeConfigs { log.Info("config save error:", err) os.Exit(-1) } + log.Info("---- ----") + log.Info("---- Welcome to forge!!! ----") + log.Info("---- ----") return cfg } @@ -170,11 +175,4 @@ func (cfg *ForgeConfigs) addSampleConfigs() { newc.Private = true newc.Directory = true cfg.Append(newc) - - newc = new(ForgeConfig) - newc.GoPath = "priv.wit.com/corp" - newc.Writable = true - newc.Private = true - newc.Directory = true - cfg.Append(newc) } diff --git a/config.common.go b/forgeConfig.Common.go index 8bc009d..8bc009d 100644 --- a/config.common.go +++ b/forgeConfig.Common.go @@ -8,6 +8,7 @@ import ( "path/filepath" "go.wit.com/lib/config" + "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) @@ -66,6 +67,26 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { os.Exit(-1) } + // todo: play with these / determine good values based on user's machine + if f.Config.RillX == 0 { + f.Config.RillX = 10 + } + if f.Config.RillY == 0 { + f.Config.RillY = 20 + } + + if !shell.Exists(f.Config.ReposPB) { + if f.Config.Mode == ForgeMode_NEWUSER { + // new user. drop back to main() for an introduction + return f + } + // create an initial repos.pb file + // panic() here? // warning? // (probably not. it's just the repos.pb cache file + f.Repos = gitpb.NewRepos() + f.Repos.Filename = f.Config.ReposPB + f.Repos.Save() + } + f.Repos = gitpb.NewRepos() f.Repos.ConfigLoad(f.Config.ReposPB) @@ -83,14 +104,6 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { } } } - - // todo: play with these / determine good values based on user's machine - if f.Config.RillX == 0 { - f.Config.RillX = 10 - } - if f.Config.RillY == 0 { - f.Config.RillY = 20 - } return f } @@ -19,7 +19,7 @@ func RunGitClone(newdir, basedir, giturl string) error { log.Info("runGitClone() basedir =", basedir) log.Info("runGitClone() giturl =", giturl) if !shell.IsDir(basedir) { - os.MkdirAll(basedir, os.ModePerm) + os.MkdirAll(basedir, 0755) } err := os.Chdir(basedir) if err != nil { |
