diff options
Diffstat (limited to 'modules/git/repo_ref.go')
-rw-r--r-- | modules/git/repo_ref.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/git/repo_ref.go b/modules/git/repo_ref.go index e1ab46e090..95a6c2ae69 100644 --- a/modules/git/repo_ref.go +++ b/modules/git/repo_ref.go @@ -31,15 +31,19 @@ func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error) { if err = refsIter.ForEach(func(ref *plumbing.Reference) error { if ref.Name() != plumbing.HEAD && !ref.Name().IsRemote() && (pattern == "" || strings.HasPrefix(ref.Name().String(), pattern)) { + refType := string(ObjectCommit) + if ref.Name().IsTag() { + // tags can be of type `commit` (lightweight) or `tag` (annotated) + if tagType, _ := repo.GetTagType(SHA1(ref.Hash())); err == nil { + refType = tagType + } + } r := &Reference{ Name: ref.Name().String(), Object: SHA1(ref.Hash()), - Type: string(ObjectCommit), + Type: refType, repo: repo, } - if ref.Name().IsTag() { - r.Type = string(ObjectTag) - } refs = append(refs, r) } return nil |