Fixup pack_management.py to handle tags that aren't on branches
@@ -241,6 +241,12 @@ def clone_repo(temp_dir, repo_url, verify_ssl=True, ref='master'):
# We're trying to figure out which branch the ref is actually on,
# since there's no direct way to check for this in git-python.
branches = repo.git.branch('-a', '--contains', gitref.hexsha) # pylint: disable=no-member
+
+ # Git tags aren't necessarily on a branch.
+ # If this is the case, gitref will be the tag name, but branches will be
+ # empty.
+ # We also need to checkout tags slightly differently than branches.
+ if branches:
branches = branches.replace('*', '').split()
if active_branch.name not in branches or use_branch:
@@ -254,6 +260,8 @@ def clone_repo(temp_dir, repo_url, verify_ssl=True, ref='master'):
repo.git.checkout(gitref.hexsha) # pylint: disable=no-member
repo.git.branch('-f', branch, gitref.hexsha) # pylint: disable=no-member
repo.git.checkout(branch)
+ else:
+ repo.git.checkout('v%s' % ref) # pylint: disable=no-member
return temp_dir
