minor new funcs

This commit is contained in:
Jeff Carr 2024-12-16 03:04:21 -06:00
parent 6922059a0b
commit a9286af8fd
1 changed files with 30 additions and 0 deletions

View File

@ -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
}