From 4326d1d259daa229819bb6ef14e2cc65312118f3 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Thu, 30 Jan 2025 14:11:27 +0100 Subject: [PATCH] fix: Sorts git tags with tagcmp --- pkg/recipe/git.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/recipe/git.go b/pkg/recipe/git.go index e2f0982d..4b0ffd2a 100644 --- a/pkg/recipe/git.go +++ b/pkg/recipe/git.go @@ -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