@@ -309,7 +309,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
309
309
#{ Edit Interface
310
310
311
311
@classmethod
312
- def add (cls , repo , name , path , url = None , branch = None , no_checkout = False ):
312
+ def add (cls , repo , name , path , url = None , branch = None , no_checkout = False , depth = None ):
313
313
"""Add a new submodule to the given repository. This will alter the index
314
314
as well as the .gitmodules file, but will not create a new commit.
315
315
If the submodule already exists, no matter if the configuration differs
@@ -334,6 +334,8 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
334
334
Examples are 'master' or 'feature/new'
335
335
:param no_checkout: if True, and if the repository has to be cloned manually,
336
336
no checkout will be performed
337
+ :param depth: Create a shallow clone with a history truncated to the
338
+ specified number of commits.
337
339
:return: The newly created submodule instance
338
340
:note: works atomically, such that no change will be done if the repository
339
341
update fails for instance"""
@@ -395,6 +397,12 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
395
397
kwargs ['b' ] = br .name
396
398
# END setup checkout-branch
397
399
400
+ if depth :
401
+ if isinstance (depth , int ):
402
+ kwargs ['depth' ] = depth
403
+ else :
404
+ raise ValueError ("depth should be an integer" )
405
+
398
406
# _clone_repo(cls, repo, url, path, name, **kwargs):
399
407
mrepo = cls ._clone_repo (repo , url , path , name , ** kwargs )
400
408
# END verify url
0 commit comments