mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-25 11:16:11 +01:00
Sort Python package descriptors by version to mimic PyPI format (#23550)
--- Hi, very naive and **untested** first time ever Go code, feel free to reject/edit this as needed. (PyPI actually performs "naive" string comparison too) --------- Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
1a4efa0ee9
commit
dbdb5ba33e
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
packages_model "code.gitea.io/gitea/models/packages"
|
||||
|
@ -62,6 +63,11 @@ func PackageMetadata(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// sort package descriptors by version to mimic PyPI format
|
||||
sort.Slice(pds, func(i, j int) bool {
|
||||
return strings.Compare(pds[i].Version.Version, pds[j].Version.Version) < 0
|
||||
})
|
||||
|
||||
ctx.Data["RegistryURL"] = setting.AppURL + "api/packages/" + ctx.Package.Owner.Name + "/pypi"
|
||||
ctx.Data["PackageDescriptor"] = pds[0]
|
||||
ctx.Data["PackageDescriptors"] = pds
|
||||
|
|
Loading…
Reference in a new issue