Only show the latest version in the Arch index (#33262)
Only show the latest version of the package in the arch repo. closes #33534 --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
42d817e814
commit
fba365b425
4 changed files with 229 additions and 41 deletions
27
services/packages/arch/vercmp_test.go
Normal file
27
services/packages/arch/vercmp_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package arch
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCompareVersions(t *testing.T) {
|
||||
// https://man.archlinux.org/man/vercmp.8.en
|
||||
checks := [][]string{
|
||||
{"1.0a", "1.0b", "1.0beta", "1.0p", "1.0pre", "1.0rc", "1.0", "1.0.a", "1.0.1"},
|
||||
{"1", "1.0", "1.1", "1.1.1", "1.2", "2.0", "3.0.0"},
|
||||
}
|
||||
for _, check := range checks {
|
||||
for i := 0; i < len(check)-1; i++ {
|
||||
require.Equal(t, -1, compareVersions(check[i], check[i+1]))
|
||||
require.Equal(t, 1, compareVersions(check[i+1], check[i]))
|
||||
}
|
||||
}
|
||||
require.Equal(t, 1, compareVersions("1.0-2", "1.0"))
|
||||
require.Equal(t, 0, compareVersions("0:1.0-1", "1.0"))
|
||||
require.Equal(t, 1, compareVersions("1:1.0-1", "2.0"))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue