summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-12 02:03:32 -0500
committerJeff Carr <[email protected]>2025-09-12 02:03:32 -0500
commite793c89712357975c564aa04a00ec33004c6ae07 (patch)
treed8b03e52c6bb72edd655bf703329241648ee0ba2 /config.go
parent9d968721d0c3f553cd2034256c95f5b6b96cb962 (diff)
yep. switch to thins
Diffstat (limited to 'config.go')
-rw-r--r--config.go30
1 files 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)