Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Edit links if version is referenced by annotated tag #3302

Merged
merged 2 commits into from Dec 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions readthedocs/vcs_support/backends/git.py
Expand Up @@ -92,15 +92,23 @@ 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 []
return self.parse_tags(stdout)

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
Expand Down