Skip to content

Commit

Permalink
Merge pull request #3441 from rtfd/fix-git
Browse files Browse the repository at this point in the history
Fix git
  • Loading branch information
ericholscher authored Dec 28, 2017
2 parents 59d8f92 + 092d8ae commit fe79c92
Showing 1 changed file with 2 additions and 10 deletions.
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

0 comments on commit fe79c92

Please sign in to comment.