summaryrefslogtreecommitdiff
path: root/Load.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-27 10:45:25 -0500
committerJeff Carr <[email protected]>2025-10-27 10:45:25 -0500
commit9e98e0b36d794d4acb7bc81909ee94598a43b37c (patch)
tree1144dea4a8676d90eb024651efad58591e3c6ceb /Load.go
parentb7e832d8a5a00ed6647735b8c9a3151cb8496899 (diff)
work on a Cache setting concept
Diffstat (limited to 'Load.go')
-rw-r--r--Load.go120
1 files changed, 0 insertions, 120 deletions
diff --git a/Load.go b/Load.go
deleted file mode 100644
index d940323..0000000
--- a/Load.go
+++ /dev/null
@@ -1,120 +0,0 @@
-// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
-// go install go.wit.com/apps/autogenpb@latest
-//
-// This file was autogenerated with autogenpb:
-// autogenpb v0.5.25-2-g30e8de2 Built on 2025/10/16 09:16:09 ( 3 m)
-// Theese sort.pb.go and marshal.pb.go files are autogenerated
-// The autogenpb sources have example .proto files with instructions
-//
-
-package forgepb
-
-import (
- "errors"
- "os"
-
- "go.wit.com/lib/config"
- "go.wit.com/lib/env"
- "go.wit.com/lib/protobuf/argvpb"
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
-func (pb *ForgeConfigs) loadConfig() error {
- pb.Filename = config.MakeConfigFilename("forge", "forge")
- err := config.ReLoad(pb)
- if env.Verbose() {
- log.Printf("%s loadConfig() about to load Config from %s\n", argvpb.GetAPPNAME(), pb.Filename)
- }
- if err != nil {
- log.Info("couldn't load filename:", pb.Filename)
- log.Info("forge has not been configured")
- panic("config failed to load. make a new/blank forge config here?")
- }
- env.SetGlobal("lib/forgepb", "ForgeCfg", pb.Filename)
- var changed bool
- // migrate from the old gopath to "namespace"
- for fc := range pb.IterAll() {
- if fc.Namespace != "" {
- continue
- }
- if fc.Namespace != fc.GoPath {
- fc.Namespace = fc.GoPath
- changed = true
- }
- // todo: deprecate this
- fc.GoPath = "" // I want to do this but it might be a bad idea at this point
- }
- if env.Verbose() {
- log.Printf("%s loadConfig() loaded Config from %s\n", argvpb.GetAPPNAME(), pb.Filename)
- }
- if changed {
- config.SetChanged("forge", true)
- }
-
- // init new config here
- return err
-}
-
-func (f *Forge) reposCacheLoad() error {
- if f.Repos != nil {
- return errors.New("already loaded")
- }
- f.Repos = gitpb.NewRepos()
- f.Repos.Filename = config.MakeCacheFilename("forge", "repos")
- err := config.ReLoad(f.Repos)
- if err == nil {
- env.SetGlobal("lib/forgepb", "ReposPB", f.Repos.Filename)
- }
- return err
-}
-
-func (f *Forge) patchesCacheLoad() error {
- if f.Patches != nil {
- return errors.New("already loaded")
- }
- f.Patches = NewPatches()
- f.Patches.Filename = config.MakeCacheFilename("forge", "patches")
- err := config.ReLoad(f.Patches)
- if errors.Is(err, os.ErrNotExist) {
- // is a new file
- f.Patches.Save()
- return os.ErrNotExist
- }
- if err != nil {
- log.Printf("patchesCacheLoad() failed err (%v) filename (%s)\n", err, f.Patches.Filename)
- panic("failed to load patches")
- }
- env.SetGlobal("lib/forgepb", "PatchesPB", f.Patches.Filename)
- return err
-}
-
-func makeDefaultConfig() (*ForgeConfigs, error) {
- cfg := NewForgeConfigs()
- // Get fullpath to ~/.config/forge/forge.text
- cfg.loadConfig()
-
- cfg.addSampleConfigs()
- env.PrintTable()
- var err error
- if err = cfg.saveVerbose(); err != nil {
- log.Info("config save error:", err)
- }
- return cfg, err
-}
-
-// first time user. add go.wit.com as an example
-func (cfg *ForgeConfigs) addSampleConfigs() {
- newc := new(ForgeConfig)
- newc.GoPath = "go.wit.com"
- newc.Writable = true
- newc.Directory = true
- cfg.Append(newc)
-
- newc = new(ForgeConfig)
- newc.GoPath = "priv.wit.com/corp"
- newc.Writable = true
- newc.Private = true
- newc.Directory = true
- cfg.Append(newc)
-}