rename vars
This commit is contained in:
parent
8aff3f13b2
commit
4f84a4e584
|
@ -98,8 +98,7 @@ func (c *ForgeConfigs) ConfigLoad() error {
|
|||
}
|
||||
|
||||
// first time user. make a template config file
|
||||
log.Info("crap")
|
||||
// c.sampleConfig()
|
||||
c.sampleConfig()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ func (c *ForgeConfigs) loadText() error {
|
|||
if err := c.UnmarshalTEXT(data); err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
18
init.go
18
init.go
|
@ -26,7 +26,7 @@ func Init() *Forge {
|
|||
f.Machine = new(zoopb.Machine)
|
||||
|
||||
if err := f.Machine.ConfigLoad(); err != nil {
|
||||
log.Warn("zoopb.ConfigLoad() failed", err)
|
||||
log.Log(WARN, "zoopb.ConfigLoad() failed", err)
|
||||
}
|
||||
if f.Config.Username == "" {
|
||||
usr, _ := user.Current()
|
||||
|
@ -40,9 +40,9 @@ func Init() *Forge {
|
|||
f.ScanGoSrc()
|
||||
end := f.Repos.Len()
|
||||
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 {
|
||||
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)
|
||||
|
@ -51,7 +51,7 @@ func Init() *Forge {
|
|||
f.ConfigSave()
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func InitPB() *Forge {
|
|||
if gosrc == "" {
|
||||
goSrcDir, err := f.findGoSrc()
|
||||
if err != nil {
|
||||
log.Warn("forge init() findGoSrc()", err)
|
||||
log.Log(WARN, "forge init() findGoSrc()", err)
|
||||
}
|
||||
os.Setenv("FORGE_GOSRC", goSrcDir)
|
||||
}
|
||||
|
@ -83,18 +83,18 @@ func InitPB() *Forge {
|
|||
}
|
||||
|
||||
// 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
|
||||
f.Config = new(ForgeConfigs)
|
||||
if err := f.Config.ConfigLoad(); err != nil {
|
||||
log.Warn("forgepb.ConfigLoad() failed", err)
|
||||
log.Log(WARN, "forgepb.ConfigLoad() failed", err)
|
||||
}
|
||||
|
||||
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 {
|
||||
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.ConfigLoad()
|
||||
|
|
16
repoNew.go
16
repoNew.go
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
|
@ -26,10 +27,22 @@ func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
|
|||
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
|
||||
// it can not be vX.X and it also can not be v0.0.0
|
||||
// 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) {
|
||||
return ValidGoVersion(ver)
|
||||
}
|
||||
|
||||
func ValidGoVersion(ver string) (bool, error) {
|
||||
if ver == "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 {
|
||||
return false, fmt.Errorf("(%s) invalid. golang versions must have exactly 3 numbers (v1.2.3)", ver)
|
||||
}
|
||||
if isValidSemVer(ver) {
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// figure out what the name of the git master branch is
|
||||
|
|
Loading…
Reference in New Issue