Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down