summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go66
1 files changed, 1 insertions, 65 deletions
diff --git a/config.go b/config.go
index bdd733b..a0c0567 100644
--- a/config.go
+++ b/config.go
@@ -8,54 +8,9 @@ import (
"go.wit.com/lib/ENV"
"go.wit.com/lib/config"
- "go.wit.com/lib/protobuf/argvpb"
"go.wit.com/log"
)
-// returns err1 || err2
-func (f *Forge) ConfigSave() error {
- if f.Config == nil {
- return log.Errorf("forge.Config == nil")
- }
-
- if !config.HasChanged("forge") {
- return nil
- }
-
- // only let forge edit & save the config files
- // inforce this in lib config?
- if !(argvpb.GetAPPNAME() == "forge" || argvpb.GetAPPNAME() == "guireleaser") {
- log.Info("This is not forge")
- return log.Errorf("Only forge can save the forge config file")
- }
-
- // migrate from the old gopath to "namespace"
- for fc := range f.Config.IterAll() {
- if fc.Namespace != "" {
- continue
- }
- if fc.Namespace != fc.GoPath {
- fc.Namespace = fc.GoPath
- }
- // todo: deprecate this
- // fc.GoPath = "" // I want to do this but it might be a bad idea at this point
- }
- log.Info("Okay, this is", argvpb.GetAPPNAME())
-
- if err := f.Config.ConfigSave(); err != nil {
- log.Info("forge.Config.ConfigSave() error", err)
- return err
- }
- return nil
-}
-
-func (f *Forge) SaveRepos() error {
- if ENV.Verbose() {
- return f.Repos.SaveVerbose()
- }
- return f.Repos.Save()
-}
-
func (f *Forge) SetMode(newmode ForgeMode) error {
if f.mode == newmode {
// nothing changed
@@ -73,25 +28,6 @@ func (f *Forge) SetMode(newmode ForgeMode) error {
return err
}
-// functions to import and export the protobuf
-// data to and from config files
-
-// write to ~/.config/forge/
-func (cfg *ForgeConfigs) ConfigSave() error {
- var header string
- header += "\n"
- header += "# the forge config file\n"
- header += "# You can customize things like:\n"
- header += "#\n"
- header += "# * which repos you have write access to\n"
- header += "# * custom branch names for 'master', 'devel' and 'user'\n"
- header += "# * 'favorites' so you can remember which things you like\n"
- header += "# * sometimes protobuf TEXT can fail so as a backup this also creates a .json file\n"
- header += "#\n"
- header += "\n"
- return config.ConfigSaveWithHeader(cfg, header)
-}
-
func loadStdConfig() (*ForgeConfigs, error) {
cfg := NewForgeConfigs()
err := cfg.loadConfig()
@@ -121,7 +57,7 @@ func makeDefaultConfig() (*ForgeConfigs, error) {
cfg.addSampleConfigs()
ENV.PrintTable()
var err error
- if err = cfg.SaveVerbose(); err != nil {
+ if err = cfg.saveVerbose(); err != nil {
log.Info("config save error:", err)
}
return cfg, err