diff options
author | 6543 <6543@obermui.de> | 2022-07-29 01:17:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 01:17:56 +0200 |
commit | ae86a0bc9fb5c65005bd37649d3bac9f7413c58c (patch) | |
tree | e11eac01db6aa0309ccbd03e978ad66b3aadfafe /routers/api/packages | |
parent | 4b53a5c3a1a830098d7fc2106e74490e242e08d9 (diff) | |
download | gitea-ae86a0bc9fb5c65005bd37649d3bac9f7413c58c.tar.gz gitea-ae86a0bc9fb5c65005bd37649d3bac9f7413c58c.zip |
packages/generic: Do not restrict package versions to SemVer (#20414) (#20531)
There are existing packages out there whose version do not conform to SemVer, yet, one would like to have them available in a generic package repository. To this end, remove the SemVer restriction on package versions when using the Generic package registry, and replace it with a check that simply makes sure the version isn't empty.
Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gergely Nagy <algernon@users.noreply.github.com>
Diffstat (limited to 'routers/api/packages')
-rw-r--r-- | routers/api/packages/generic/generic.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go index d862f77259..9a3a185d9d 100644 --- a/routers/api/packages/generic/generic.go +++ b/routers/api/packages/generic/generic.go @@ -8,6 +8,7 @@ import ( "errors" "net/http" "regexp" + "strings" packages_model "code.gitea.io/gitea/models/packages" "code.gitea.io/gitea/modules/context" @@ -15,8 +16,6 @@ import ( packages_module "code.gitea.io/gitea/modules/packages" "code.gitea.io/gitea/routers/api/packages/helper" packages_service "code.gitea.io/gitea/services/packages" - - "github.com/hashicorp/go-version" ) var ( @@ -97,8 +96,7 @@ func UploadPackage(ctx *context.Context) { Name: packageName, Version: packageVersion, }, - SemverCompatible: true, - Creator: ctx.Doer, + Creator: ctx.Doer, }, &packages_service.PackageFileCreationInfo{ PackageFileInfo: packages_service.PackageFileInfo{ @@ -157,10 +155,10 @@ func sanitizeParameters(ctx *context.Context) (string, string, string, error) { return "", "", "", errors.New("Invalid package name or filename") } - v, err := version.NewSemver(ctx.Params("packageversion")) - if err != nil { - return "", "", "", err + packageVersion := strings.TrimSpace(ctx.Params("packageversion")) + if packageVersion == "" { + return "", "", "", errors.New("Invalid package version") } - return packageName, v.String(), filename, nil + return packageName, packageVersion, filename, nil } |