diff options
author | Liam Beguin <liambeguin@gmail.com> | 2020-05-02 14:37:58 -0400 |
---|---|---|
committer | Liam Beguin <liambeguin@gmail.com> | 2020-05-02 16:08:58 -0400 |
commit | d6e1dcc992ff0a8ddcb4bca281ae34e9bc0df34b (patch) | |
tree | 2b30925dca022afc7a59d7b691de5bdbe7f47fa2 /git | |
parent | 09a96fb2ea908e20d5acb7445d542fa2f8d10bb6 (diff) | |
download | gitpython-d6e1dcc992ff0a8ddcb4bca281ae34e9bc0df34b.tar.gz |
allow setting depth when cloning a submodule
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Diffstat (limited to 'git')
-rw-r--r-- | git/objects/submodule/base.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index f41ec13b..4629f82d 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -309,7 +309,7 @@ class Submodule(IndexObject, Iterable, Traversable): #{ Edit Interface @classmethod - def add(cls, repo, name, path, url=None, branch=None, no_checkout=False): + def add(cls, repo, name, path, url=None, branch=None, no_checkout=False, depth=None): """Add a new submodule to the given repository. This will alter the index as well as the .gitmodules file, but will not create a new commit. If the submodule already exists, no matter if the configuration differs @@ -334,6 +334,8 @@ class Submodule(IndexObject, Iterable, Traversable): Examples are 'master' or 'feature/new' :param no_checkout: if True, and if the repository has to be cloned manually, no checkout will be performed + :param depth: Create a shallow clone with a history truncated to the + specified number of commits. :return: The newly created submodule instance :note: works atomically, such that no change will be done if the repository update fails for instance""" @@ -395,6 +397,12 @@ class Submodule(IndexObject, Iterable, Traversable): kwargs['b'] = br.name # END setup checkout-branch + if depth: + if isinstance(depth, int): + kwargs['depth'] = depth + else: + raise ValueError("depth should be an integer") + # _clone_repo(cls, repo, url, path, name, **kwargs): mrepo = cls._clone_repo(repo, url, path, name, **kwargs) # END verify url |