rm GOSRC
This commit is contained in:
parent
5a98058474
commit
9d968721d0
14
config.go
14
config.go
|
@ -12,12 +12,12 @@ import (
|
|||
"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 {
|
||||
if os.Getenv("FORGE_GOSRC") == "" {
|
||||
if os.Getenv("FORGE_REPOSDIR") == "" {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
fullpath := filepath.Join(homeDir, ".config/forge")
|
||||
os.Setenv("FORGE_GOSRC", fullpath)
|
||||
os.Setenv("FORGE_REPOSDIR", fullpath)
|
||||
}
|
||||
if 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
|
||||
// locally just for speed
|
||||
func (all *Repos) ConfigLoad() error {
|
||||
if os.Getenv("FORGE_GOSRC") == "" {
|
||||
if os.Getenv("FORGE_REPOSDIR") == "" {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
fullpath := filepath.Join(homeDir, ".config/forge")
|
||||
os.Setenv("FORGE_GOSRC", fullpath)
|
||||
os.Setenv("FORGE_REPOSDIR", fullpath)
|
||||
}
|
||||
var data []byte
|
||||
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 {
|
||||
// something went wrong loading the file
|
||||
// all.sampleConfig() // causes nil panic
|
||||
|
@ -147,7 +147,7 @@ func loadFile(fullname string) ([]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))
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
|
|
Loading…
Reference in New Issue