summaryrefslogtreecommitdiff
path: root/repoNew.go
diff options
context:
space:
mode:
Diffstat (limited to 'repoNew.go')
-rw-r--r--repoNew.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/repoNew.go b/repoNew.go
index 17adeb2..d5caa18 100644
--- a/repoNew.go
+++ b/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)
}
- return true, nil
+ if isValidSemVer(ver) {
+ return true, nil
+ }
+ return false, nil
}
// figure out what the name of the git master branch is