summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-10-24 16:10:47 +0200
committerGuido Günther <agx@sigxcpu.org>2011-10-26 09:45:10 +0200
commit113ac4ed020c3bf65dbf7517599a8105c521bf91 (patch)
treea8233c881ac31a34339d0b8eb68daebef439a482
parent5b8a7aba07f1ae09ff3c80360e1c18b8756d0e58 (diff)
GitRepository.clone(): add depth and recursive parameter
-rw-r--r--gbp/git.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/gbp/git.py b/gbp/git.py
index d049f15..a7b5fba 100644
--- a/gbp/git.py
+++ b/gbp/git.py
@@ -929,7 +929,7 @@ class GitRepository(object):
return None
@classmethod
- def clone(klass, path, remote):
+ def clone(klass, path, remote, depth=0, recursive=False):
"""
Clone a git repository at I{path}
@@ -937,15 +937,21 @@ class GitRepository(object):
@type path: string
@param remote: URL to clone
@type remote: string
+ @param depth: create a shallow clone of depth I{depth}
+ @type depth: int
+ @param recursive: whether to clone submodules
+ @type recursive: bool
@return: git repository object
@rtype:GitRepository
"""
abspath = os.path.abspath(path)
+ args = [ '--depth', depth ] if depth else []
+ args += [ '--recursive' ] if recursive else []
try:
if not os.path.exists(abspath):
os.makedirs(abspath)
- GitCommand("clone", [remote], cwd=abspath)()
+ GitCommand("clone", args + [remote], cwd=abspath)()
(clone, dummy) = os.path.splitext(remote.rstrip('/').rsplit('/',1)[1])
return klass(os.path.join(abspath, clone))
except OSError, err: