Skip to content

Commit

Permalink
Add missing return when removing broken ref
Browse files Browse the repository at this point in the history
  • Loading branch information
ruairif committed Feb 24, 2017
1 parent 88f264c commit f5b1649
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions portia_server/storage/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ def checkout(self, commit=None, branch=None, retry=True):
try:
commit = self.repo._repo.get_object(_commit_id)
except ObjectMissing:
del self.repo._repo.refs[ref]
if ref != 'refs/heads/master':
del self.repo._repo.refs[ref]
else:
six.reraise(*sys.exc_info())
else:
break
if commit is not None and isinstance(commit, string_types):
Expand All @@ -228,8 +231,11 @@ def checkout(self, commit=None, branch=None, retry=True):
tree = self.repo._repo.get_object(commit.tree)
except ObjectMissing:
if retry and branch is not None:
del self.repo._repo.refs['refs/heads/%s' % branch]
self.checkout(branch='master', retry=False)
if branch != 'master':
del self.repo._repo.refs['refs/heads/%s' % branch]
return self.checkout(branch='master', retry=False)
else:
six.reraise(*sys.exc_info())
self._tree = tree
self._working_tree = tree.copy()
self._blobs = {}
Expand Down

0 comments on commit f5b1649

Please sign in to comment.