minor new funcs
This commit is contained in:
parent
6922059a0b
commit
a9286af8fd
30
repoNew.go
30
repoNew.go
|
@ -1,9 +1,12 @@
|
||||||
package forgepb
|
package forgepb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Forge) NewGoPathRepo(gopath string) (*gitpb.Repo, error) {
|
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
|
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) {
|
func (f *Forge) VerifyBranchNames(newr *gitpb.Repo) {
|
||||||
// log.Info("init worked for", newr.GoPath)
|
// log.Info("init worked for", newr.GoPath)
|
||||||
|
|
||||||
|
@ -98,3 +119,12 @@ func (f *Forge) configDevelBranchName(repo *gitpb.Repo) string {
|
||||||
}
|
}
|
||||||
return "devel"
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue