From 69c681e3eaff21746e1c457496bf38169db00b14 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 29 Apr 2021 11:47:50 +0200 Subject: [PATCH] Fix tag sorting for recent git versions We now manually sort the tags because the behavior seems to have changed with recent git versions. Signed-off-by: Sascha Grunert --- pkg/git/git.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/git/git.go b/pkg/git/git.go index e9252a81711..227540fb771 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -930,13 +930,16 @@ func (r *Repo) TagsForBranch(branch string) (res []string, err error) { defer func() { err = r.Checkout(previousBranch) }() status, err := command.NewWithWorkDir( - r.Dir(), gitExecutable, "tag", "--sort=-creatordate", "--merged", + r.Dir(), gitExecutable, "tag", "--sort=creatordate", "--merged", ).RunSilentSuccessOutput() if err != nil { return nil, errors.Wrapf(safeError(err), "retrieving merged tags for branch %s", branch) } - return strings.Fields(status.Output()), nil + tags := strings.Fields(status.Output()) + sort.Sort(sort.Reverse(sort.StringSlice(tags))) + + return tags, nil } // Tags returns a list of tags for the repository.