diff --git a/refs.go b/refs.go index 722e24a..b344fea 100644 --- a/refs.go +++ b/refs.go @@ -95,6 +95,9 @@ func Fetch(url string, options ...Option) (map[string]string, error) { parts := strings.SplitN(string(line), " ", 2) hash := parts[0] ref := strings.TrimSpace(strings.SplitN(parts[1], "\000", 2)[0]) + if strings.HasSuffix(ref, "^{}") { + continue + } if !o.tagsOnly || strings.HasPrefix(ref, tagPrefix) { refs[ref] = hash } diff --git a/tags_test.go b/tags_test.go index 1c1e66d..54e0ba7 100644 --- a/tags_test.go +++ b/tags_test.go @@ -51,6 +51,11 @@ func Test_latestTag(t *testing.T) { "refs/tags/v1.0.0": commit1, "refs/tags/1.0.0": commit2, }, "", "1.0.0", commit2, false}, + {"Dereferenced tags should be filtered", map[string]string{ + "refs/tags/v1.0.0": commit1, + "refs/tags/v1.0.0^{}": commit2, + "refs/tags/v1.0.1": commit3, + }, "", "v1.0.1", commit3, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {