yep. switch to thins
This commit is contained in:
parent
9d968721d0
commit
e793c89712
30
config.go
30
config.go
|
@ -81,7 +81,7 @@ func (all *Repos) tryValidate() error {
|
||||||
// load the repos.pb file. I shouldn't really matter if this
|
// load the repos.pb file. I shouldn't really matter if this
|
||||||
// fails. the file should be autogenerated. This is used
|
// fails. the file should be autogenerated. This is used
|
||||||
// locally just for speed
|
// locally just for speed
|
||||||
func (all *Repos) ConfigLoad() error {
|
func (all *Repos) ConfigLoadOld() error {
|
||||||
if os.Getenv("FORGE_REPOSDIR") == "" {
|
if os.Getenv("FORGE_REPOSDIR") == "" {
|
||||||
homeDir, _ := os.UserHomeDir()
|
homeDir, _ := os.UserHomeDir()
|
||||||
fullpath := filepath.Join(homeDir, ".config/forge")
|
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
|
// this means the forge.pb file exists and was read
|
||||||
if len(data) == 0 {
|
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")
|
return errors.New("gitpb.ConfigLoad() repos.pb is empty")
|
||||||
}
|
}
|
||||||
err = all.Unmarshal(data)
|
err = all.Unmarshal(data)
|
||||||
|
|
Loading…
Reference in New Issue