diff mbox

SV: Bakery clone branch argument support

Message ID BD22328D0EB182418C2A0952DC2454F83F071DA0@VMPREVAS2.prevas.se
State Changes Requested
Delegated to: Esben Haabendal
Headers show

Commit Message

kim.hansen@prevas.dk May 13, 2014, 12:25 p.m. UTC
It "works" but we need the branch arg take effect when making a bare clone as well.

See attached format-patch.

Comments

kim.hansen@prevas.dk May 13, 2014, 12:26 p.m. UTC | #1
Regarding a 4.2.0 with this stuff applied, yes please

/Kim
Esben Haabendal May 13, 2014, 1:02 p.m. UTC | #2
Kim Højgaard-Hansen <Kim.Hansen@prevas.dk> writes:

> It "works" but we need the branch arg take effect when making a bare
> clone as well.
>
> See attached format-patch.

Please dont send patches as attachment, as it makes it hard reply with
inline comments/questions.

In this case, I would like to have commented something about the
approach you took, which will now come out-of-context here:

I think that if you add an optional "branch=None" argument to
clone_bare_recursive, instead of the "options, submodule=False"
arguments, that the code will be a bit easier to read (and shorter).

/Esben
diff mbox

Patch

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(-)

diff --git a/oebakery/cmd/clone.py b/oebakery/cmd/clone.py
index 0d9ac5b..ab7cb82 100644
--- a/oebakery/cmd/clone.py
+++ b/oebakery/cmd/clone.py
@@ -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