gbp-clone: support cloning to a specific directory
authorGuan Junchun <junchunx.guan@intel.com>
Fri, 11 Oct 2013 10:16:17 +0000 (18:16 +0800)
committerGuido Günther <agx@sigxcpu.org>
Tue, 22 Oct 2013 11:39:11 +0000 (13:39 +0200)
Closes: #725666

Signed-off-by: Guan Junchun <junchunx.guan@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/clone.py

index 5f21329..15e1174 100755 (executable)
@@ -59,21 +59,23 @@ def main(argv):
 
     (options, args) = parse_args(argv)
 
-    if len(args) != 2:
+    if len(args) < 2:
         gbp.log.err("Need a repository to clone.")
         return 1
     else:
         source = args[1]
 
+    clone_to, auto_name = (os.path.curdir, True) if len(args) < 3 else (args[2], False)
     try:
-        GitRepository(os.path.curdir)
+        GitRepository(clone_to)
         gbp.log.err("Can't run inside a git repository.")
         return 1
     except GitRepositoryError:
         pass
 
     try:
-        repo = DebianGitRepository.clone(os.path.curdir, source, options.depth)
+        repo = DebianGitRepository.clone(clone_to, source, options.depth,
+                                         auto_name=auto_name)
         os.chdir(repo.path)
 
         # Reparse the config files of the cloned repository so we pick up the