rename vars

This commit is contained in:
Jeff Carr 2025-01-08 04:08:12 -06:00
parent 8aff3f13b2
commit 4f84a4e584
3 changed files with 28 additions and 13 deletions

View File

@ -98,8 +98,7 @@ func (c *ForgeConfigs) ConfigLoad() error {
} }
// first time user. make a template config file // first time user. make a template config file
log.Info("crap") c.sampleConfig()
// c.sampleConfig()
return nil return nil
} }
@ -121,7 +120,7 @@ func (c *ForgeConfigs) loadText() error {
if err := c.UnmarshalTEXT(data); err != nil { if err := c.UnmarshalTEXT(data); err != nil {
return err return err
} }
log.Info("forge.ConfigLoad()", len(c.ForgeConfigs), "entries in ~/.config/forge") log.Log(INFO, "forge.ConfigLoad()", len(c.ForgeConfigs), "entries in ~/.config/forge")
return nil return nil
} }

18
init.go
View File

@ -26,7 +26,7 @@ func Init() *Forge {
f.Machine = new(zoopb.Machine) f.Machine = new(zoopb.Machine)
if err := f.Machine.ConfigLoad(); err != nil { if err := f.Machine.ConfigLoad(); err != nil {
log.Warn("zoopb.ConfigLoad() failed", err) log.Log(WARN, "zoopb.ConfigLoad() failed", err)
} }
if f.Config.Username == "" { if f.Config.Username == "" {
usr, _ := user.Current() usr, _ := user.Current()
@ -40,9 +40,9 @@ func Init() *Forge {
f.ScanGoSrc() f.ScanGoSrc()
end := f.Repos.Len() end := f.Repos.Len()
if (end - start) == 0 { if (end - start) == 0 {
log.Info("forgepb.Scan() Scan did not find new git repositories. Total =", end) log.Log(INFO, "forgepb.Scan() Scan did not find new git repositories. Total =", end)
} else { } else {
log.Info("forgepb.Scan() Scan found", end-start, "new git repositories. Total =", end) log.Log(INFO, "forgepb.Scan() Scan found", end-start, "new git repositories. Total =", end)
} }
f.rillUpdate(20, 10) f.rillUpdate(20, 10)
@ -51,7 +51,7 @@ func Init() *Forge {
f.ConfigSave() f.ConfigSave()
f.configSave = false f.configSave = false
} }
log.Info("update() check took", shell.FormatDuration(time.Since(now))) log.Log(INFO, "update() check took", shell.FormatDuration(time.Since(now)))
return f return f
} }
@ -64,7 +64,7 @@ func InitPB() *Forge {
if gosrc == "" { if gosrc == "" {
goSrcDir, err := f.findGoSrc() goSrcDir, err := f.findGoSrc()
if err != nil { if err != nil {
log.Warn("forge init() findGoSrc()", err) log.Log(WARN, "forge init() findGoSrc()", err)
} }
os.Setenv("FORGE_GOSRC", goSrcDir) os.Setenv("FORGE_GOSRC", goSrcDir)
} }
@ -83,18 +83,18 @@ func InitPB() *Forge {
} }
// print out the settings that will be used // print out the settings that will be used
log.Info("forgepb.Init() FORGE_CONFIG", os.Getenv("FORGE_CONFIG")) log.Log(INFO, "forgepb.Init() FORGE_CONFIG", os.Getenv("FORGE_CONFIG"))
// load the ~/.config/forge/ config // load the ~/.config/forge/ config
f.Config = new(ForgeConfigs) f.Config = new(ForgeConfigs)
if err := f.Config.ConfigLoad(); err != nil { if err := f.Config.ConfigLoad(); err != nil {
log.Warn("forgepb.ConfigLoad() failed", err) log.Log(WARN, "forgepb.ConfigLoad() failed", err)
} }
if f.IsGoWork() { if f.IsGoWork() {
log.Info("forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = true)") log.Log(INFO, "forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = true)")
} else { } else {
log.Info("forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = false)") log.Log(INFO, "forgepb.Init() FORGE_GOSRC ", os.Getenv("FORGE_GOSRC"), "(go.work = false)")
} }
f.Repos = new(gitpb.Repos) f.Repos = new(gitpb.Repos)
f.Repos.ConfigLoad() f.Repos.ConfigLoad()

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
"go.wit.com/lib/protobuf/gitpb" "go.wit.com/lib/protobuf/gitpb"
@ -26,10 +27,22 @@ func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
return repo, nil return repo, nil
} }
func isValidSemVer(version string) bool {
// Regular expression for semantic versioning
regex := `^v(\d+)\.(\d+)\.(\d+)$`
matched, _ := regexp.MatchString(regex, version)
return matched
}
// golang versions MUST be vX.X.X // golang versions MUST be vX.X.X
// it can not be vX.X and it also can not be v0.0.0 // it can not be vX.X and it also can not be v0.0.0
// verifies the version is format v3.2.1 // verifies the version is format v3.2.1
// this is retardedly wrong. it needs to be done right
func (f *Forge) ValidGoVersion(ver string) (bool, error) { func (f *Forge) ValidGoVersion(ver string) (bool, error) {
return ValidGoVersion(ver)
}
func ValidGoVersion(ver string) (bool, error) {
if ver == "v0.0.0" { if ver == "v0.0.0" {
return false, fmt.Errorf("golang does not allow version v0.0.0") return false, fmt.Errorf("golang does not allow version v0.0.0")
} }
@ -41,7 +54,10 @@ func (f *Forge) ValidGoVersion(ver string) (bool, error) {
if len(parts) != 3 { if len(parts) != 3 {
return false, fmt.Errorf("(%s) invalid. golang versions must have exactly 3 numbers (v1.2.3)", ver) return false, fmt.Errorf("(%s) invalid. golang versions must have exactly 3 numbers (v1.2.3)", ver)
} }
if isValidSemVer(ver) {
return true, nil return true, nil
}
return false, nil
} }
// figure out what the name of the git master branch is // figure out what the name of the git master branch is