summaryrefslogtreecommitdiffstats
path: root/modules/packages
diff options
context:
space:
mode:
authorGergely Nagy <algernon@users.noreply.github.com>2022-07-22 23:54:02 +0200
committerGitHub <noreply@github.com>2022-07-22 22:54:02 +0100
commit4d22bda4db4c29e61ff4ac7a53ab25e7ff8a55a3 (patch)
tree2bc60e99a7548430000967d85b22847592225bec /modules/packages
parent599ae09a94e40f9ef567aa2ec7486f68a64a3384 (diff)
downloadgitea-4d22bda4db4c29e61ff4ac7a53ab25e7ff8a55a3.tar.gz
gitea-4d22bda4db4c29e61ff4ac7a53ab25e7ff8a55a3.zip
Allow non-semver packages in the Conan package registry (#20412)
A lot of existing packages do not conform to SemVer, yet, they should be allowed in the Conan package registry as-is. To achieve this, remove the SemVer check from `NewRecipeReference`, and replace it with a simple empty string check. A unit test with a non-semver version is also included. Fixes #20405. Signed-off-by: Gergely Nagy <me@gergo.csillger.hu> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'modules/packages')
-rw-r--r--modules/packages/conan/reference.go9
-rw-r--r--modules/packages/conan/reference_test.go1
2 files changed, 6 insertions, 4 deletions
diff --git a/modules/packages/conan/reference.go b/modules/packages/conan/reference.go
index c43446e6e5..49236981b6 100644
--- a/modules/packages/conan/reference.go
+++ b/modules/packages/conan/reference.go
@@ -8,10 +8,9 @@ import (
"errors"
"fmt"
"regexp"
+ "strings"
"code.gitea.io/gitea/modules/log"
-
- goversion "github.com/hashicorp/go-version"
)
const (
@@ -56,7 +55,9 @@ func NewRecipeReference(name, version, user, channel, revision string) (*RecipeR
if !namePattern.MatchString(name) {
return nil, ErrValidation
}
- if _, err := goversion.NewSemver(version); err != nil {
+
+ v := strings.TrimSpace(version)
+ if v == "" {
return nil, ErrValidation
}
if user != "" && !namePattern.MatchString(user) {
@@ -69,7 +70,7 @@ func NewRecipeReference(name, version, user, channel, revision string) (*RecipeR
return nil, ErrValidation
}
- return &RecipeReference{name, version, user, channel, revision}, nil
+ return &RecipeReference{name, v, user, channel, revision}, nil
}
func (r *RecipeReference) RevisionOrDefault() string {
diff --git a/modules/packages/conan/reference_test.go b/modules/packages/conan/reference_test.go
index 29ba3a543b..98eb2c8478 100644
--- a/modules/packages/conan/reference_test.go
+++ b/modules/packages/conan/reference_test.go
@@ -34,6 +34,7 @@ func TestNewRecipeReference(t *testing.T) {
{"name", "1.0", "_", "_", "", true},
{"name", "1.0", "_", "_", "0", true},
{"name", "1.0", "", "", "0", true},
+ {"name", "1.0.0q", "", "", "0", true},
{"name", "1.0", "", "", "000000000000000000000000000000000000000000000000000000000000", false},
}