diff --git a/renku/command/clone.py b/renku/command/clone.py index f4f26c6ba5..6a4a0cf1da 100644 --- a/renku/command/clone.py +++ b/renku/command/clone.py @@ -33,7 +33,7 @@ def _project_clone( install_githooks: bool = True, install_mergetool: bool = True, skip_smudge: bool = True, - recursive: bool = True, + recursive: bool = False, depth: Optional[int] = None, progress: Optional[RemoteProgress] = None, config: Optional[Dict[str, Any]] = None, @@ -49,7 +49,7 @@ def _project_clone( install_githooks(bool): Whether to install the pre-commit hook or not (Default value = True). install_mergetool(bool): Whether to install the renku metadata git mergetool or not (Default value = True). skip_smudge(bool): Whether to skip pulling files from LFS (Default value = True). - recursive(bool): Recursively clone (Default value = True). + recursive(bool): Recursively clone (Default value = False). depth(Optional[int]): Clone depth (commits from HEAD) (Default value = None). progress(Optional[RemoteProgress]): Git progress object (Default value = None). config(Optional[Dict[str, Any]]): Initial config (Default value = None). diff --git a/renku/core/util/git.py b/renku/core/util/git.py index cd167454c8..33d43dba9a 100644 --- a/renku/core/util/git.py +++ b/renku/core/util/git.py @@ -625,7 +625,7 @@ def clone_renku_repository( install_githooks=False, install_lfs=True, skip_smudge=True, - recursive=True, + recursive=False, progress=None, config: Optional[dict] = None, raise_git_except=False, @@ -644,7 +644,7 @@ def clone_renku_repository( install_githooks: Whether to install git hooks (Default value = False). install_lfs: Whether to install Git LFS (Default value = True). skip_smudge: Whether to pull files from Git LFS (Default value = True). - recursive: Whether to clone recursively (Default value = True). + recursive: Whether to clone recursively (Default value = False). progress: The GitProgress object (Default value = None). config(Optional[dict], optional): Set configuration for the project (Default value = None). raise_git_except: Whether to raise git exceptions (Default value = False). @@ -710,7 +710,7 @@ def clone_repository( install_githooks=True, install_lfs=True, skip_smudge=True, - recursive=True, + recursive=False, depth=None, progress=None, config: Optional[dict] = None, @@ -728,7 +728,7 @@ def clone_repository( install_githooks: Whether to install git hooks (Default value = True). install_lfs: Whether to install Git LFS (Default value = True). skip_smudge: Whether to pull files from Git LFS (Default value = True). - recursive: Whether to clone recursively (Default value = True). + recursive: Whether to clone recursively (Default value = False). depth: The clone depth, number of commits from HEAD (Default value = None). progress: The GitProgress object (Default value = None). config(Optional[dict], optional): Set configuration for the project (Default value = None). @@ -760,7 +760,7 @@ def handle_git_exception(): raise errors.GitError(message) - def clean_directory(): + def clean_directory(clean: bool): if not clean or not path: return try: @@ -791,10 +791,10 @@ def check_and_reuse_existing_repository() -> Optional["Repository"]: pass else: # NOTE: not same remote, so don't reuse - clean_directory() + clean_directory(clean=clean) return None except errors.GitError: # NOTE: Not a git repository, remote not found, or checkout failed - clean_directory() + clean_directory(clean=clean) else: return repository @@ -828,6 +828,9 @@ def clone(branch, depth): handle_git_exception() raise + # NOTE: Delete the partially-cloned repository + clean_directory(clean=True) + # NOTE: clone without branch set, in case checkout_revision was not a branch or a tag but a commit try: repository = clone(branch=None, depth=None)