Skip to content

Commit

Permalink
add submodules to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclotruc committed Feb 15, 2025
1 parent bd9f697 commit 62e9856
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/gitingest/repository_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,30 @@ async def clone_repo(config: CloneConfig) -> tuple[bytes, bytes]:
if commit:
# Scenario 1: Clone and checkout a specific commit
# Clone the repository without depth to ensure full history for checkout
clone_cmd = ["git", "clone", "--single-branch", url, local_path]
clone_cmd = ["git", "clone", "--recurse-submodules", "--single-branch", url, local_path]
await _run_git_command(*clone_cmd)

# Checkout the specific commit
checkout_cmd = ["git", "-C", local_path, "checkout", commit]
return await _run_git_command(*checkout_cmd)

if branch and branch.lower() not in ("main", "master"):

# Scenario 2: Clone a specific branch with shallow depth
clone_cmd = ["git", "clone", "--depth=1", "--single-branch", "--branch", branch, url, local_path]
clone_cmd = [
"git",
"clone",
"--recurse-submodules",
"--depth=1",
"--single-branch",
"--branch",
branch,
url,
local_path,
]
return await _run_git_command(*clone_cmd)

# Scenario 3: Clone the default branch with shallow depth
clone_cmd = ["git", "clone", "--depth=1", "--single-branch", url, local_path]
clone_cmd = ["git", "clone", "--recurse-submodules", "--depth=1", "--single-branch", url, local_path]
return await _run_git_command(*clone_cmd)


Expand Down

0 comments on commit 62e9856

Please sign in to comment.