Skip to content

Try to fix annotated tags #6959

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

Merged
merged 4 commits into from
Apr 27, 2020
Merged
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
11 changes: 8 additions & 3 deletions readthedocs/vcs_support/backends/git.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-

"""Git-related utilities."""

import logging
import os
import re

import git
from gitdb.util import hex_to_bin
from django.core.exceptions import ValidationError
from git.exc import BadName, InvalidGitRepositoryError

Expand Down Expand Up @@ -207,8 +206,14 @@ def tags(self):
# Build a cache of tag -> commit
# GitPython is not very optimized for reading large numbers of tags
ref_cache = {} # 'ref/tags/<tag>' -> hexsha
# This code is the same that is executed for each tag in gitpython,
# we excute it only once for all tags.
for hexsha, ref in git.TagReference._iter_packed_refs(repo):
ref_cache[ref] = hexsha
gitobject = git.Object.new_from_sha(repo, hex_to_bin(hexsha))
if gitobject.type == 'commit':
ref_cache[ref] = str(gitobject)
elif gitobject.type == 'tag' and gitobject.object.type == 'commit':
ref_cache[ref] = str(gitobject.object)

for tag in repo.tags:
if tag.path in ref_cache:
Expand Down