summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-08 13:22:09 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-08 13:22:09 +0100
commit94c70b2a9df151ed409b549614c5bdf019791e5f (patch)
treec3ab09a25e955e2f7f405651a67df7196c0bf725
parent216fd8f6f477c074d42577809aefdf4633823992 (diff)
downloadlorry-94c70b2a9df151ed409b549614c5bdf019791e5f.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.
-rwxr-xr-xlorry21
1 files changed, 19 insertions, 2 deletions
diff --git a/lorry b/lorry
index b52a193..e1d2cf4 100755
--- a/lorry
+++ b/lorry
@@ -287,9 +287,26 @@ class Lorry(cliapp.Application):
self.progress('.. initialising git dir')
self.run_program(['git', 'init', '--bare', gitdir])
self.progress('.. updating existing clone')
- self.run_program(['git', 'fetch', spec['url'],
- '+refs/heads/*:refs/heads/*',
+ if 'remote.origin.fetch' in self.run_program(['git', 'config', '-l'],
+ cwd=gitdir):
+ self.run_program(['git', 'config', '--unset-all',
+ 'remote.origin.fetch'], cwd=gitdir)
+ self.run_program(['git', 'config', 'remote.origin.url',
+ spec['url']], cwd=gitdir)
+ self.run_program(['git', 'config', 'remote.origin.mirror', 'true'],
+ cwd=gitdir)
+ self.run_program(['git', 'config', '--add', 'remote.origin.fetch',
+ '+refs/heads/*:refs/heads/*'], cwd=gitdir)
+ self.run_program(['git', 'config', '--add', 'remote.origin.fetch',
'+refs/tags/*:refs/tags/*'], cwd=gitdir)
+ try:
+ self.run_program(['git', 'remote', 'update', 'origin', '--prune'],
+ cwd=gitdir)
+ except:
+ self.run_program(['git', 'remote', 'prune', 'origin'],
+ cwd=gitdir)
+ self.run_program(['git', 'remote', 'update', 'origin', '--prune'],
+ cwd=gitdir)
def gitify_bzr(self, project_name, dirname, gitdir, spec):
bzrdir = os.path.join(dirname, 'bzr')