fix: Sorts git tags with tagcmp

This commit is contained in:
p4u1 2025-01-30 14:11:27 +01:00 committed by decentral1se
parent b976872f77
commit 4326d1d259

View File

@ -4,11 +4,13 @@ import (
"fmt"
"os"
"slices"
"sort"
"strings"
"coopcloud.tech/abra/pkg/formatter"
gitPkg "coopcloud.tech/abra/pkg/git"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/tagcmp"
"github.com/distribution/reference"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
@ -345,6 +347,18 @@ func (r Recipe) Tags() ([]string, error) {
return tags, err
}
sort.Slice(tags, func(i, j int) bool {
version1, err := tagcmp.Parse(tags[i])
if err != nil {
return false
}
version2, err := tagcmp.Parse(tags[j])
if err != nil {
return false
}
return version1.IsLessThan(version2)
})
log.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name)
return tags, nil