From a9286af8fd3f912aa357e3ebe67af09f42b8d534 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 16 Dec 2024 03:04:21 -0600 Subject: [PATCH] minor new funcs --- repoNew.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/repoNew.go b/repoNew.go index b87ee4c..772e9b2 100644 --- a/repoNew.go +++ b/repoNew.go @@ -1,9 +1,12 @@ package forgepb import ( + "fmt" "os/user" + "strings" "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" ) func (f *Forge) NewGoPathRepo(gopath string) (*gitpb.Repo, error) { @@ -16,6 +19,24 @@ func (f *Forge) NewGoPathRepo(gopath string) (*gitpb.Repo, error) { return repo, nil } +// 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 +func (f *Forge) ValidGoVersion(ver string) (bool, error) { + if ver == "v0.0.0" { + return false, fmt.Errorf("golang does not allow version v0.0.0") + } + if !strings.HasPrefix(ver, "v") { + return false, fmt.Errorf("(%s) invalid. golang versions must start with a 'v'", ver) + } + xver := ver[1:] + parts := strings.Split(xver, ".") + if len(parts) != 3 { + return false, fmt.Errorf("(%s) invalid. golang versions must have exactly 3 numbers (v1.2.3)", ver) + } + return true, nil +} + func (f *Forge) VerifyBranchNames(newr *gitpb.Repo) { // log.Info("init worked for", newr.GoPath) @@ -98,3 +119,12 @@ func (f *Forge) configDevelBranchName(repo *gitpb.Repo) string { } return "devel" } + +func (f *Forge) AddFullPath(fulldir string) *gitpb.Repo { + repo := f.Repos.FindByFullPath(fulldir) + if repo != nil { + return repo + } + log.Info("don't know how to add full paths yet", fulldir) + return nil +}