diff --git a/vcstool/__init__.py b/vcstool/__init__.py index f5e9f249..878c7585 100644 --- a/vcstool/__init__.py +++ b/vcstool/__init__.py @@ -1,3 +1,3 @@ from .clients import vcstool_clients # noqa -__version__ = '0.3.0' +__version__ = '0.3.1' diff --git a/vcstool/clients/git.py b/vcstool/clients/git.py index ae1ae8bb..c1b3895c 100644 --- a/vcstool/clients/git.py +++ b/vcstool/clients/git.py @@ -313,6 +313,8 @@ def import_(self, command): # fetch updates for existing repo cmd_fetch = [GitClient._executable, 'fetch', remote] + if command.partial_clone: + cmd_fetch.append("--filter=blob:none") if command.shallow: result_version_type, version_name = self._check_version_type( command.url, checkout_version) @@ -386,7 +388,10 @@ def import_(self, command): if not command.shallow or version_type in (None, 'branch'): cmd_clone = [GitClient._executable, 'clone', command.url, '.'] - if version_type == 'branch': + if command.partial_clone: + cmd_clone += ["--filter=blob:none", "--no-checkout"] + checkout_version = command.version + elif version_type == 'branch': cmd_clone += ['-b', version_name] checkout_version = None else: diff --git a/vcstool/commands/import_.py b/vcstool/commands/import_.py index 55b3e184..472edb5a 100644 --- a/vcstool/commands/import_.py +++ b/vcstool/commands/import_.py @@ -34,6 +34,7 @@ def __init__( self.skip_existing = args.skip_existing self.recursive = recursive self.shallow = shallow + self.partial_clone = args.partial_clone def get_parser(): @@ -60,6 +61,10 @@ def get_parser(): '--skip-existing', action='store_true', default=False, help="Don't overwrite existing directories or change custom checkouts " 'in repos using the same URL (but fetch repos with same URL)') + group.add_argument( + '--partial-clone', action='store_true', default=False, + help="Only clone the partial git first, then checkout to the target version" + ) return parser