diff options
| -rw-r--r-- | config.go | 3 | ||||
| -rw-r--r-- | forgeConfig.proto | 9 | ||||
| -rw-r--r-- | humanForgedTable.go | 4 | ||||
| -rw-r--r-- | init.go | 32 | ||||
| -rw-r--r-- | patchset.config.go | 7 |
5 files changed, 41 insertions, 14 deletions
@@ -60,12 +60,13 @@ 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.PatchDir = %s\n", cfg.PatchDir) + log.Infof("CfgPB.PatchPB = %s\n", cfg.PatchPB) log.Infof("CfgPB.ForgeURL = %s\n", cfg.ForgeURL) if cfg.GoWork { log.Infof("CfgPB.GoWork = %v\n", cfg.GoWork) } log.Infof("CfgPB.Mode = %s\n", cfg.Mode) + log.Infof("CfgPB.PatchDir = %s #deprecate\n", cfg.PatchDir) // log.Infof("CfgPB.Hostname=%s\n", cfg.Hostname) } diff --git a/forgeConfig.proto b/forgeConfig.proto index ec081d0..9733bb0 100644 --- a/forgeConfig.proto +++ b/forgeConfig.proto @@ -60,10 +60,11 @@ message ForgeConfigs { // `autogenpb:mar string ReposPB = 11; // where the repos.pb is string ReposDir = 12; // where the repos are string PatchDir = 13; // patch dir - string ForgeURL = 14; // forge URL - string Filename = 15; // filename of the config file - int32 rillX = 16; // used by rill - int32 rillY = 17; // used by rill + string PatchPB = 14; // fullpath to patches file + string ForgeURL = 15; // forge URL + string Filename = 16; // filename of the config file + int32 rillX = 17; // used by rill + int32 rillY = 18; // used by rill } // this generic message is used by autogen to identify and diff --git a/humanForgedTable.go b/humanForgedTable.go index e1d93b5..b727f2b 100644 --- a/humanForgedTable.go +++ b/humanForgedTable.go @@ -8,7 +8,6 @@ import ( func (f *Forge) PrintForgedTable(pb *gitpb.Repos) { tablePB := f.makeForgedTable(pb) - tablePB.MakeTable() tablePB.PrintTable() } @@ -16,8 +15,7 @@ func (f *Forge) makeForgedTable(pb *gitpb.Repos) *gitpb.ReposTable { t := pb.NewTable("forgedList") t.NewUuid() - col := t.AddNamespace() - col.Width = 28 + var col *gitpb.RepoAnyFunc col = t.AddMasterVersion() col.Width = 15 @@ -67,6 +67,29 @@ func InitByAppname(argname string) *Forge { return f } +func InitByFullpath(filename string) *Forge { + cfg := NewForgeConfigs() + err := config.LoadFile(cfg, filename) + if err != nil { + log.Info("forge load config err", err) + os.Exit(-1) + } + return InitByConfig(cfg) +} + +func InitByConfig(cfg *ForgeConfigs) *Forge { + if cfg == nil { + log.Info("forge config was == nil") + os.Exit(-1) + } + f := new(Forge) + f.Config = cfg + f.initFromConfig() + + log.Printf("forge.InitByConfig() %s Repos.len()=%d\n", f.Config.Filename, f.Repos.Len()) + return f +} + func (f *Forge) initFromConfig() { if f.configENV() { log.Info("ENV changed config. todo: save config here") @@ -81,8 +104,15 @@ func (f *Forge) initFromConfig() { f.Repos = gitpb.NewRepos() f.Repos.ConfigLoad(f.Config.ReposPB) - // init the Patchsets f.Patchsets = NewSets() + if f.Config.PatchPB == "" { + // init default Patchsets? + // save patchsets here? + } else { + if err := config.LoadFile(f.Patchsets, f.Config.PatchPB); err != nil { + log.Info("forge.Init() load patches failed", err) + } + } // todo: play with these / determine good values based on user's machine if f.Config.RillX == 0 { diff --git a/patchset.config.go b/patchset.config.go index 3762d55..4957850 100644 --- a/patchset.config.go +++ b/patchset.config.go @@ -3,7 +3,6 @@ package forgepb import ( "fmt" "os" - "path/filepath" "regexp" "strings" @@ -16,9 +15,7 @@ import ( func (f *Forge) LoadPatchsets() error { f.Patchsets = NewSets() - filename := filepath.Join(f.Config.PatchDir, "all-patches.pb") - - data, err := os.ReadFile(filename) + data, err := os.ReadFile(f.Config.PatchPB) if err != nil { return err } @@ -45,7 +42,7 @@ func (f *Forge) InitPatchsets() error { } func (f *Forge) SavePatchsets() error { - filename := filepath.Join(f.Config.PatchDir, "all-patches.pb") + filename := f.Config.PatchPB regfile, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) if err != nil { log.Info("SavePatchsets() filename open error:", filename, err) |
