From 8cb66071ac11dbdd1596431157eb68d3089cbc35 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Thu, 20 Feb 2025 02:52:23 +0300 Subject: [PATCH] feat(git_utils): enhance git_cmd_clone with depth and single-branch options Signed-off-by: Aleksei Sviridkin --- kiauh/utils/git_utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kiauh/utils/git_utils.py b/kiauh/utils/git_utils.py index a658607..ac2ae39 100644 --- a/kiauh/utils/git_utils.py +++ b/kiauh/utils/git_utils.py @@ -253,11 +253,16 @@ def get_remote_commit(repo: Path) -> str | None: return None -def git_cmd_clone(repo: str, target_dir: Path) -> None: +def git_cmd_clone(repo: str, target_dir: Path, depth: int = 1) -> None: try: - command = ["git", "clone", repo, target_dir.as_posix()] + command = [ + "git", "clone", + "--depth", str(depth), + "--single-branch", + repo, + target_dir.as_posix() + ] run(command, check=True) - Logger.print_ok("Clone successful!") except CalledProcessError as e: error = e.stderr.decode() if e.stderr else "Unknown error"