Skip to content

Commit da10ce8

Browse files
6543KN4CK3Ralgernon
authored
Allow non-semver packages in the Conan package registry (#20412) (#20523)
Backport #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 <[email protected]> Co-authored-by: KN4CK3R <[email protected]> Co-authored-by: Gergely Nagy <[email protected]>
1 parent 4ed32e7 commit da10ce8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

modules/packages/conan/reference.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import (
88
"errors"
99
"fmt"
1010
"regexp"
11+
"strings"
1112

1213
"code.gitea.io/gitea/modules/log"
13-
14-
goversion "github.com/hashicorp/go-version"
1514
)
1615

1716
const (
@@ -56,7 +55,9 @@ func NewRecipeReference(name, version, user, channel, revision string) (*RecipeR
5655
if !namePattern.MatchString(name) {
5756
return nil, ErrValidation
5857
}
59-
if _, err := goversion.NewSemver(version); err != nil {
58+
59+
v := strings.TrimSpace(version)
60+
if v == "" {
6061
return nil, ErrValidation
6162
}
6263
if user != "" && !namePattern.MatchString(user) {
@@ -69,7 +70,7 @@ func NewRecipeReference(name, version, user, channel, revision string) (*RecipeR
6970
return nil, ErrValidation
7071
}
7172

72-
return &RecipeReference{name, version, user, channel, revision}, nil
73+
return &RecipeReference{name, v, user, channel, revision}, nil
7374
}
7475

7576
func (r *RecipeReference) RevisionOrDefault() string {

modules/packages/conan/reference_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestNewRecipeReference(t *testing.T) {
3434
{"name", "1.0", "_", "_", "", true},
3535
{"name", "1.0", "_", "_", "0", true},
3636
{"name", "1.0", "", "", "0", true},
37+
{"name", "1.0.0q", "", "", "0", true},
3738
{"name", "1.0", "", "", "000000000000000000000000000000000000000000000000000000000000", false},
3839
}
3940

0 commit comments

Comments
 (0)