mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-24 10:46:10 +01:00
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 <me@gergo.csillger.hu> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Gergely Nagy <algernon@users.noreply.github.com>
This commit is contained in:
parent
4ed32e79b6
commit
da10ce8b07
|
@ -8,10 +8,9 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
|
||||||
goversion "github.com/hashicorp/go-version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -56,7 +55,9 @@ func NewRecipeReference(name, version, user, channel, revision string) (*RecipeR
|
||||||
if !namePattern.MatchString(name) {
|
if !namePattern.MatchString(name) {
|
||||||
return nil, ErrValidation
|
return nil, ErrValidation
|
||||||
}
|
}
|
||||||
if _, err := goversion.NewSemver(version); err != nil {
|
|
||||||
|
v := strings.TrimSpace(version)
|
||||||
|
if v == "" {
|
||||||
return nil, ErrValidation
|
return nil, ErrValidation
|
||||||
}
|
}
|
||||||
if user != "" && !namePattern.MatchString(user) {
|
if user != "" && !namePattern.MatchString(user) {
|
||||||
|
@ -69,7 +70,7 @@ func NewRecipeReference(name, version, user, channel, revision string) (*RecipeR
|
||||||
return nil, ErrValidation
|
return nil, ErrValidation
|
||||||
}
|
}
|
||||||
|
|
||||||
return &RecipeReference{name, version, user, channel, revision}, nil
|
return &RecipeReference{name, v, user, channel, revision}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RecipeReference) RevisionOrDefault() string {
|
func (r *RecipeReference) RevisionOrDefault() string {
|
||||||
|
|
|
@ -34,6 +34,7 @@ func TestNewRecipeReference(t *testing.T) {
|
||||||
{"name", "1.0", "_", "_", "", true},
|
{"name", "1.0", "_", "_", "", true},
|
||||||
{"name", "1.0", "_", "_", "0", true},
|
{"name", "1.0", "_", "_", "0", true},
|
||||||
{"name", "1.0", "", "", "0", true},
|
{"name", "1.0", "", "", "0", true},
|
||||||
|
{"name", "1.0.0q", "", "", "0", true},
|
||||||
{"name", "1.0", "", "", "000000000000000000000000000000000000000000000000000000000000", false},
|
{"name", "1.0", "", "", "000000000000000000000000000000000000000000000000000000000000", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue