summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo.py
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-08 12:20:52 +0000
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-08 12:20:52 +0000
commit8e11f8f59d59c0d9f9a2cc517eeef47a1a200fb1 (patch)
tree5528f1b703524726385263f5251c3cb83277ead4 /morphlib/cachedrepo.py
parentc3a6ba962c71ca69a6496d0d30ee23f0669ed763 (diff)
downloadmorph-8e11f8f59d59c0d9f9a2cc517eeef47a1a200fb1.tar.gz
Handle branch name kind changes more gracefully.
Scenario: a repository contains a ref: refs/heads/foo and we have that in our repository cache. Action: upstream deletes that ref and then pushes a new refs at refs/heads/foo/bar. Action: we attempt to update the git and the update fails because git remote update cannot cope with the 'kind' change of refs/heads/foo from ref to directory. Remedy: If we get an exception from the remote update --prune we try the less efficient but more resilient combination of first pruning and then updating. Reviewed-By: Lars Wirzenius (over the shoulder) Reviewed-By: Richard Maw (over the shoulder)
Diffstat (limited to 'morphlib/cachedrepo.py')
-rw-r--r--morphlib/cachedrepo.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py
index f0ca627b..c40cb657 100644
--- a/morphlib/cachedrepo.py
+++ b/morphlib/cachedrepo.py
@@ -271,7 +271,11 @@ class CachedRepo(object):
raise CheckoutError(self, ref, target_dir)
def _update(self): # pragma: no cover
- self._runcmd(['git', 'remote', 'update', 'origin', '--prune'])
+ try:
+ self._runcmd(['git', 'remote', 'update', 'origin', '--prune'])
+ except cliapp.AppException, ae:
+ self._runcmd(['git', 'remote', 'prune', 'origin'])
+ self._runcmd(['git', 'remote', 'update', 'origin'])
def __str__(self): # pragma: no cover
return self.url