From bdcd1497c44f2cd15a8c6e26a2110bcb427cdbcf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kim=20H=C3=B8jgaard-Hansen?= <kiho@prevas.dk>
Date: Tue, 13 May 2014 12:21:02 +0000
Subject: [PATCH] clone: make it possible to clone bare/mirror for a specific
branch
Without this it is not possible to correctly mirror a repository
that previously had more submodules than in current master since
these would not be cloned.
---
oebakery/cmd/clone.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
@@ -78,14 +78,20 @@ def clone_checkout(options):
def clone_bare(options):
global clone_cmd
- clone_cmd = 'git clone %s %%s %%s'%(
+ clone_cmd = 'git clone %s %%s %%s %%s'%(
['--bare', '--mirror'][int(options.mirror)])
- failed = clone_bare_recursive(options.repository, options.directory)
+ failed = clone_bare_recursive(options.repository, options.directory, options)
if failed:
return "failed repositories: %s"%(', '.join(failed))
-def clone_bare_recursive(repository, directory):
- if not oebakery.call(clone_cmd%(repository, directory)):
+def clone_bare_recursive(repository, directory, options, submodule=False):
+ if not submodule and options.branch:
+ #only clone using branch on the top level repository
+ #to get the wanted state of submodules
+ cmd = clone_cmd%('--branch %s'%(options.branch),repository, directory)
+ else:
+ cmd = clone_cmd%("",repository, directory)
+ if not oebakery.call(cmd):
logger.error("bare clone of module %s failed", directory)
return [directory]
gitmodules = oebakery.call(
@@ -100,7 +106,7 @@ def clone_bare_recursive(repository, directory):
if url != './' + path: # only clone relative submodules
continue
ret = clone_bare_recursive(
- os.path.join(repository, path), os.path.join(directory, path))
+ os.path.join(repository, path), os.path.join(directory, path),options,submodule=True)
if ret:
failed.extend(ret)
return failed
--
1.8.4