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 git #3441

Merged
merged 2 commits into from
Dec 28, 2017
Merged

Fix git #3441

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
12 changes: 2 additions & 10 deletions readthedocs/vcs_support/backends/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,15 @@ def clone(self):

@property
def tags(self):
# 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')
retcode, stdout, _ = self.run('git', 'show-ref', '--tags')
# error (or no tags found)
if retcode != 0:
return []
return self.parse_tags(stdout)

def parse_tags(self, data):
"""
Parses output of `git show-ref --tags`, eg:
Parses output of show-ref --tags, eg:

3b32886c8d3cb815df3793b3937b2e91d0fb00f1 refs/tags/2.0.0
bd533a768ff661991a689d3758fcfe72f455435d refs/tags/2.0.1
Expand Down