diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2020-05-04 18:02:39 +0800 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2020-05-04 18:02:39 +0800 |
commit | c2fd537b5b3bb062a26c9b16a52236b2625ff44c (patch) | |
tree | f58cdf878c3628e44ae9c288596daabd459d391d /git/objects/submodule/base.py | |
parent | e236853b14795edec3f09c50ce4bb0c4efad6176 (diff) | |
parent | 18dd177fbfb63caed9322867550a95ffbc2f19d8 (diff) | |
download | gitpython-c2fd537b5b3bb062a26c9b16a52236b2625ff44c.tar.gz |
Merge branch 'Liambeguin-submodule-depth'
Diffstat (limited to 'git/objects/submodule/base.py')
-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 |