diff options
| -rw-r--r-- | config.common.go | 16 | ||||
| -rw-r--r-- | config.go | 55 | ||||
| -rw-r--r-- | forgeConfig.proto | 5 | ||||
| -rw-r--r-- | human.go | 2 | ||||
| -rw-r--r-- | init.go | 2 |
5 files changed, 59 insertions, 21 deletions
diff --git a/config.common.go b/config.common.go index 5a230a8..ff70e08 100644 --- a/config.common.go +++ b/config.common.go @@ -41,7 +41,7 @@ func (all *ForgeConfigs) UpdateGoPath(name string, gopath string) bool { func (fc *ForgeConfigs) IsReadOnly(gopath string) bool { var match *ForgeConfig - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == gopath { @@ -102,7 +102,7 @@ func (fc *ForgeConfigs) DebName(gopath string) string { // get "zookeeper" from "go.wit.com/apps/zookeeper" normalBase := filepath.Base(gopath) - all := fc.SortByGoPath() + all := fc.All() for all.Scan() { r := all.Next() if r.GoPath == gopath { @@ -142,7 +142,7 @@ func (fc *ForgeConfigs) IsPrivate(thing string) bool { // sort by path means the simple 'match' logic // here works in the sense the last directory match // is the one that is used - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == thing { @@ -183,7 +183,7 @@ func (fc *ForgeConfigs) IsPrivate(thing string) bool { func (fc *ForgeConfigs) IsFavorite(thing string) bool { var match *ForgeConfig - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == thing { @@ -216,7 +216,7 @@ func (fc *ForgeConfigs) IsFavorite(thing string) bool { func (fc *ForgeConfigs) IsWritable(thing string) bool { var match *ForgeConfig - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == thing { @@ -247,7 +247,7 @@ func (fc *ForgeConfigs) IsWritable(thing string) bool { func (fc *ForgeConfigs) FindUserBranch(thing string) string { var match *ForgeConfig - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == thing { @@ -278,7 +278,7 @@ func (fc *ForgeConfigs) FindUserBranch(thing string) string { func (fc *ForgeConfigs) FindDevelBranch(thing string) string { var match *ForgeConfig - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == thing { @@ -309,7 +309,7 @@ func (fc *ForgeConfigs) FindDevelBranch(thing string) string { func (fc *ForgeConfigs) FindMasterBranch(thing string) string { var match *ForgeConfig - all := fc.SortByGoPath() // get the list of repos + all := fc.All() // get the list of repos for all.Scan() { r := all.Next() if r.GoPath == thing { @@ -30,6 +30,16 @@ func (f *Forge) ConfigSave() error { log.Info("This is not forge") return log.Errorf("Only forge can save the forge config file") } + + // migrate from the old gopath to "namespace" + for fc := range f.Config.IterAll() { + if fc.Namespace != "" { + continue + } + if fc.Namespace != fc.GoPath { + fc.Namespace = fc.GoPath + } + } log.Info("Okay, this is", prep.AppName()) if err := f.Config.ConfigSave(); err != nil { @@ -63,18 +73,23 @@ func (cfg *ForgeConfigs) ConfigSave() error { } func (cfg *ForgeConfigs) DumpENV() { - log.Infof("CfgPB.Filename = %s\n", cfg.Filename) - log.Infof("CfgPB.ReposPB = %s\n", cfg.ReposPB) - log.Infof("CfgPB.ReposDir = %s\n", cfg.ReposDir) - log.Infof("CfgPB.PatchPB = %s\n", cfg.PatchPB) - log.Infof("CfgPB.ForgeURL = %s\n", cfg.ForgeURL) + log.Info("s/DumpENV/DumpPB/") + cfg.DumpPB() +} + +func (cfg *ForgeConfigs) DumpPB() { + log.Infof("Config.Filename = %s\n", cfg.Filename) + log.Infof("Config.ReposPB = %s\n", cfg.ReposPB) + log.Infof("Config.ReposDir = %s\n", cfg.ReposDir) + log.Infof("Config.PatchPB = %s\n", cfg.PatchPB) + log.Infof("Config.ForgeURL = %s\n", cfg.ForgeURL) if cfg.GoWork { - log.Infof("CfgPB.GoWork = %v\n", cfg.GoWork) + log.Infof("Config.GoWork = %v\n", cfg.GoWork) } if cfg.Mode != ForgeMode_UNKNOWN { - log.Infof("CfgPB.Mode = %s\n", cfg.Mode) + log.Infof("Config.Mode = %s\n", cfg.Mode) } - // log.Infof("CfgPB.Hostname=%s\n", cfg.Hostname) + // log.Infof("ConfigCfgPB.Hostname=%s\n", cfg.Hostname) } /* @@ -127,6 +142,7 @@ func loadStdConfig() *ForgeConfigs { cfg.PatchPB = filepath.Join(cfgdir, "patches.pb") cfg.ForgeURL = "http://forge.wit.com/" + cfg.addSampleConfigs() cfg.DumpENV() config.SetChanged("forge", true) if !fhelp.QuestionUser("This is your first time using forge, use these default values?") { @@ -138,3 +154,26 @@ func loadStdConfig() *ForgeConfigs { } return cfg } + +// first time user. add go.wit.com as an example +func (cfg *ForgeConfigs) addSampleConfigs() { + newc := new(ForgeConfig) + newc.GoPath = "go.wit.com" + newc.Writable = 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) + + newc = new(ForgeConfig) + newc.GoPath = "priv.wit.com/corp" + newc.Writable = true + newc.Private = true + newc.Directory = true + cfg.Append(newc) +} diff --git a/forgeConfig.proto b/forgeConfig.proto index 29b454a..4ad363c 100644 --- a/forgeConfig.proto +++ b/forgeConfig.proto @@ -16,7 +16,7 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time // due to the prior apache foundation project. This happens and is ok! message ForgeConfig { // `autogenpb:nomutex` - string goPath = 1; // `autogenpb:unique` `autogenpb:sort` // Examples: 'go.wit.com/apps/go-clone' or "~/mythings" or "/home/src/foo" + string namespace = 1; // `autogenpb:unique` `autogenpb:sort` // Examples: 'go.wit.com/apps/go-clone' or "~/mythings" or "/home/src/foo" bool writable = 2; // if you have write access to the repo bool readOnly = 3; // the opposite, but needed for now because I don't know what I'm doing @@ -34,8 +34,7 @@ message ForgeConfig { // `autogenpb:nom // so we can make easier instructions for new linux users. KISS google.protobuf.Timestamp verstamp = 12; // the git commit timestamp of the version - string goSrc = 13; // is ~/go/src unless a go.work file is found - string namespace = 14; // `autogenpb:unique` `autogenpb:sort` + string goPath = 13; // deprecate } enum ForgeMode { @@ -57,7 +57,7 @@ func (f *Forge) ConfigPrintTable() { return } log.Info(standardHeader()) - all := f.Config.SortByGoPath() + all := f.Config.All() for all.Scan() { r := all.Next() log.Info(f.standardHeader(r)) @@ -61,7 +61,7 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { f.Config.ConfigSave() } if _, s := filepath.Split(f.Config.ReposPB); s != "repos.pb" { - f.Config.DumpENV() + f.Config.DumpPB() log.Infof("ReposPB invalid filename '%s'\n", f.Config.ReposPB) os.Exit(-1) } |
