diff options
Diffstat (limited to 'lorry')
-rwxr-xr-x | lorry | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -471,6 +471,8 @@ class Lorry(cliapp.Application): shutil.rmtree(temp_repo) if active_count == 0: + # We can't create the repo here because "git cvsimport" + # and "git svn init" insist on doing so themselves return temp_repo, None, 1 self.copy_gitdir(active_repo, temp_repo) @@ -481,6 +483,17 @@ class Lorry(cliapp.Application): with open(count_name, 'w') as count_file: count_file.write('%d\n' % count) + def ensure_gitdir(self, gitdir): + # Create git directory if it doesn't exist. Return flag for + # whether we created it. + exists = os.path.exists(gitdir) + if not exists: + self.progress('.. creating git repo') + self.run_program(['git', 'init', '--bare', gitdir]) + else: + self.progress('.. updating existing clone') + return not exists + def copy_gitdir(self, source, dest): if not os.path.exists(source): return None @@ -516,10 +529,7 @@ class Lorry(cliapp.Application): env = dict(os.environ) env['GIT_SSL_NO_VERIFY'] = 'true' - if not os.path.exists(gitdir): - self.progress('.. initialising git dir') - self.run_program(['git', 'init', '--bare', gitdir]) - self.progress('.. updating existing clone') + self.ensure_gitdir(gitdir) argv = ['git', '-c', 'gc.autodetach=false', 'fetch', '--prune', spec['url'], '+refs/heads/*:refs/heads/*', '+refs/tags/*:refs/tags/*'] @@ -538,11 +548,7 @@ class Lorry(cliapp.Application): self.progress('.. creating bzr repository') self.run_program([bzr, 'init-repo', '--no-trees', bzrdir]) - if not os.path.exists(gitdir): - self.progress('.. creating git repo') - os.mkdir(gitdir) - self.run_program(['git', 'init', '--bare', gitdir]) - self.needs_aggressive = True + self.needs_aggressive = self.ensure_gitdir(gitdir) # branches are the listed branches, plus the branch specified in url if 'branches' in spec: @@ -692,9 +698,7 @@ class Lorry(cliapp.Application): self.run_program(['hg', 'clone', '--quiet', *cert_options, spec['url'], hgdir]) - if not os.path.exists(gitdir): - self.needs_aggressive = True - self.run_program(['git', 'init', '--bare', gitdir]) + self.needs_aggressive = self.ensure_gitdir(gitdir) # Since there are marks files in existing deployments that # have broken references, fix up the marks file before rather @@ -737,8 +741,7 @@ class Lorry(cliapp.Application): else: self.progress('.. no need to run, nothing to do') return - if not os.path.exists(gitdir): - self.run_program(['git', 'init', '--bare', gitdir]) + self.ensure_gitdir(gitdir) cmdline = ["%s.%s-importer" % (lorry_path, archive_type), archive_dest] self.run_program(cmdline, cwd=gitdir) |