diff --git a/internal/pipe/git/git.go b/internal/pipe/git/git.go index 46b63d326f3..4dab42f62f1 100644 --- a/internal/pipe/git/git.go +++ b/internal/pipe/git/git.go @@ -177,7 +177,7 @@ func getTag() (string, error) { return os.Getenv("GORELEASER_CURRENT_TAG"), nil }, func() (string, error) { - return git.Clean(git.Run("tag", "--points-at", "HEAD", "--sort", "-version:creatordate")) + return git.Clean(git.Run("tag", "--points-at", "HEAD", "--sort", "-version:refname")) }, func() (string, error) { return git.Clean(git.Run("describe", "--tags", "--abbrev=0")) diff --git a/internal/pipe/git/git_test.go b/internal/pipe/git/git_test.go index 51eae779197..6ff67260d5b 100644 --- a/internal/pipe/git/git_test.go +++ b/internal/pipe/git/git_test.go @@ -233,10 +233,7 @@ func TestTagFromCI(t *testing.T) { envs map[string]string expected string }{ - // It is not possible to concisely figure out the tag if a commit has more than one tags. Git always - // returns the tags in lexicographical order (ASC), which implies that we expect v0.0.1 here. - // More details: https://github.com/goreleaser/goreleaser/issues/1163 - {expected: "v0.0.1"}, + {expected: "v0.0.2"}, { envs: map[string]string{"GORELEASER_CURRENT_TAG": "v0.0.2"}, expected: "v0.0.2",