Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
allow setting depth when cloning a submodule
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
  • Loading branch information
liambeguin committed May 2, 2020
commit d6e1dcc992ff0a8ddcb4bca281ae34e9bc0df34b
10 changes: 9 additions & 1 deletion git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
#{ 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
Expand All @@ -334,6 +334,8 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
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"""
Expand Down Expand Up @@ -395,6 +397,12 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
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
Expand Down