summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go33
1 files changed, 14 insertions, 19 deletions
diff --git a/config.go b/config.go
index 4034f66..d86d05a 100644
--- a/config.go
+++ b/config.go
@@ -43,7 +43,6 @@ func (f *ForgeConfigs) ConfigSave() error {
return err
}
log.Info("forgepb.ConfigSave() proto.Marshal() worked len", len(data))
- configWrite("forge.pb", data)
s := f.FormatTEXT()
configWrite("forge.text", []byte(s))
@@ -68,19 +67,6 @@ func (c *ForgeConfigs) ConfigLoad() error {
return errors.New("It's not safe to run ConfigLoad() on a nil")
}
- if data, err := loadFile("forge.pb"); err == nil {
- if data != nil {
- if len(data) != 0 {
- if err = c.Unmarshal(data); err == nil {
- log.Info("forge.ConfigLoad()", len(c.ForgeConfigs), "entries in ~/.config/forge")
- return nil
- }
- }
- }
- }
- log.Warn("broken forge.pb config file")
-
- // forge.db doesn't exist. try forge.text
// this lets the user hand edit the config
if data, err := loadFile("forge.text"); err == nil {
if data != nil {
@@ -99,7 +85,8 @@ func (c *ForgeConfigs) ConfigLoad() error {
}
// forge.text doesn't exist. try forge.json
- // this lets the user hand edit the config
+ // this lets the user hand edit the JSON config
+ // probably just deprecate this
if data, err := loadFile("forge.json"); err != nil {
if data != nil {
// this means the forge.json file exists and was read
@@ -154,13 +141,21 @@ func configWrite(filename string, data []byte) error {
}
if filename == "forge.text" {
// add header
- cfgfile.Write([]byte("# this file is automatically re-generated from forge.pb, however,\n"))
- cfgfile.Write([]byte("# if you want to edit it by hand, you can:\n"))
- cfgfile.Write([]byte("# stop forge; remove forge.pb; edit forge.text; start forge\n"))
- cfgfile.Write([]byte("# this will cause the default behavior to fallback to parsing this file for the config\n"))
cfgfile.Write([]byte("\n"))
cfgfile.Write([]byte("# this file is intended to be used to customize settings on what\n"))
cfgfile.Write([]byte("# git repos you have write access to. That is, where you can run 'git push'\n"))
+ cfgfile.Write([]byte("\n"))
+ }
+ if filename == "forge.json" {
+ // add header
+ cfgfile.Write([]byte("\n"))
+ cfgfile.Write([]byte("# this file is intended to be used to customize settings on what\n"))
+ cfgfile.Write([]byte("# git repos you have write access to. That is, where you can run 'git push'\n"))
+ cfgfile.Write([]byte("\n"))
+ cfgfile.Write([]byte("# this file is parsed only if forge.text is missing\n"))
+ cfgfile.Write([]byte("# also, these comment lines don't work in json files and have to be removed for Marshal() to work\n"))
+ cfgfile.Write([]byte("# probably, JSON syntax for this is just going to be deprecated for the TEXT syntax\n"))
+ cfgfile.Write([]byte("\n"))
}
cfgfile.Write(data)
return nil