diff --git a/readthedocs/vcs_support/backends/git.py b/readthedocs/vcs_support/backends/git.py index 52010d28486..2230f47f054 100644 --- a/readthedocs/vcs_support/backends/git.py +++ b/readthedocs/vcs_support/backends/git.py @@ -80,7 +80,15 @@ def clone(self): @property def tags(self): - retcode, stdout, _ = self.run('git', 'show-ref', '--tags') + # Hash for non-annotated tag is its commit hash, but for annotated tag it + # points to tag itself, so we need to dereference annotated tags. + # The output format is the same as `git show-ref --tags`, but with hashes + # of annotated tags pointing to tagged commits. + retcode, stdout, _ = self.run( + 'git', 'for-each-ref', + '--format="%(if)%(*objectname)%(then)%(*objectname)' + '%(else)%(objectname)%(end) %(refname)"', + 'refs/tags') # error (or no tags found) if retcode != 0: return [] @@ -88,7 +96,7 @@ def tags(self): def parse_tags(self, data): """ - Parses output of show-ref --tags, eg: + Parses output of `git show-ref --tags`, eg: 3b32886c8d3cb815df3793b3937b2e91d0fb00f1 refs/tags/2.0.0 bd533a768ff661991a689d3758fcfe72f455435d refs/tags/2.0.1