This commit is contained in:
Jeff Carr 2025-09-11 23:10:49 -05:00
parent 5a98058474
commit 9d968721d0
1 changed files with 7 additions and 7 deletions

View File

@ -12,12 +12,12 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
// write to ~/.config/forge/ unless ENV{FORGE_GOSRC} is set // write to ~/.config/forge/ unless ENV{FORGE_REPOSDIR} is set
func (all *Repos) ConfigSave() error { func (all *Repos) ConfigSave() error {
if os.Getenv("FORGE_GOSRC") == "" { if os.Getenv("FORGE_REPOSDIR") == "" {
homeDir, _ := os.UserHomeDir() homeDir, _ := os.UserHomeDir()
fullpath := filepath.Join(homeDir, ".config/forge") fullpath := filepath.Join(homeDir, ".config/forge")
os.Setenv("FORGE_GOSRC", fullpath) os.Setenv("FORGE_REPOSDIR", fullpath)
} }
if all == nil { if all == nil {
log.Warn("gitpb all == nil") log.Warn("gitpb all == nil")
@ -82,15 +82,15 @@ func (all *Repos) tryValidate() error {
// 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) ConfigLoad() error {
if os.Getenv("FORGE_GOSRC") == "" { if os.Getenv("FORGE_REPOSDIR") == "" {
homeDir, _ := os.UserHomeDir() homeDir, _ := os.UserHomeDir()
fullpath := filepath.Join(homeDir, ".config/forge") fullpath := filepath.Join(homeDir, ".config/forge")
os.Setenv("FORGE_GOSRC", fullpath) os.Setenv("FORGE_REPOSDIR", fullpath)
} }
var data []byte var data []byte
var err error var err error
cfgname := filepath.Join(os.Getenv("FORGE_GOSRC"), "repos.pb") cfgname := filepath.Join(os.Getenv("FORGE_REPOSDIR"), "repos.pb")
if data, err = loadFile(cfgname); err != nil { if data, err = loadFile(cfgname); err != nil {
// something went wrong loading the file // something went wrong loading the file
// all.sampleConfig() // causes nil panic // all.sampleConfig() // causes nil panic
@ -147,7 +147,7 @@ func loadFile(fullname string) ([]byte, error) {
} }
func configWrite(filename string, data []byte) error { func configWrite(filename string, data []byte) error {
fullname := filepath.Join(os.Getenv("FORGE_GOSRC"), filename) fullname := filepath.Join(os.Getenv("FORGE_REPOSDIR"), filename)
log.Infof("%s your repos have changed state. cached state. (%d) bytes\n", fullname, len(data)) log.Infof("%s your repos have changed state. cached state. (%d) bytes\n", fullname, len(data))
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)