From e793c89712357975c564aa04a00ec33004c6ae07 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 12 Sep 2025 02:03:32 -0500 Subject: [PATCH] yep. switch to thins --- config.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index a12cd0e..9167b17 100644 --- a/config.go +++ b/config.go @@ -81,7 +81,7 @@ func (all *Repos) tryValidate() error { // load the repos.pb file. I shouldn't really matter if this // fails. the file should be autogenerated. This is used // locally just for speed -func (all *Repos) ConfigLoad() error { +func (all *Repos) ConfigLoadOld() error { if os.Getenv("FORGE_REPOSDIR") == "" { homeDir, _ := os.UserHomeDir() fullpath := filepath.Join(homeDir, ".config/forge") @@ -98,7 +98,33 @@ func (all *Repos) ConfigLoad() error { } // this means the forge.pb file exists and was read if len(data) == 0 { - all.sampleConfig() // causes nil panic + return errors.New("gitpb.ConfigLoad() repos.pb is empty") + } + err = all.Unmarshal(data) + test := NewRepos() + if test.Uuid != all.Uuid { + log.Log(WARN, "uuids do not match", test.Uuid, all.Uuid) + deleteProtobufFile(cfgname) + } + if test.Version != all.Version { + log.Log(WARN, "versions do not match", test.Version, all.Version) + deleteProtobufFile(cfgname) + } + log.Log(INFO, cfgname, "protobuf versions and uuid match", all.Uuid, all.Version) + return err +} + +func (all *Repos) ConfigLoad(cfgname string) error { + var data []byte + var err error + + if data, err = loadFile(cfgname); err != nil { + // something went wrong loading the file + // all.sampleConfig() // causes nil panic + return err + } + // this means the forge.pb file exists and was read + if len(data) == 0 { return errors.New("gitpb.ConfigLoad() repos.pb is empty") } err = all.Unmarshal(data)