Skip to content

Commit 2bf124b

Browse files
authored
fix: use remote with .git suffix as main clone url (#4301)
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent cf92690 commit 2bf124b

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

services/apps/git_integration/src/crowdgit/services/clone/clone_service.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
retry_on_clone_error = retry(
4949
retry=retry_if_exception_type(RETRYABLE_CLONE_ERRORS),
50-
stop=stop_after_attempt(6),
50+
stop=stop_after_attempt(3),
5151
wait=wait_exponential(multiplier=5, min=5, max=120),
5252
reraise=True,
5353
)
@@ -190,9 +190,14 @@ async def _perform_minimal_clone(self, path: str, remote: str) -> None:
190190
Perform minimal clone of depth=1
191191
"""
192192
self.logger.info("Initializing minimal clone")
193-
await run_shell_command(
194-
["git", "clone", "--depth=1", "--no-tags", "--single-branch", remote, "."], cwd=path
195-
)
193+
base_cmd = ["git", "clone", "--depth=1", "--no-tags", "--single-branch"]
194+
try:
195+
await run_shell_command([*base_cmd, f"{remote}.git", "."], cwd=path)
196+
except Exception:
197+
self.logger.warning(
198+
f"Clone with .git suffix failed, falling back to bare URL: {remote}"
199+
)
200+
await run_shell_command([*base_cmd, remote, "."], cwd=path)
196201
self.logger.info("Minimal clone initialized successfully")
197202

198203
async def _get_repo_size_mb(self, repo_path: str) -> float:
@@ -377,9 +382,14 @@ async def _cleanup_working_directory(self, repo_path: str) -> None:
377382
async def _perform_full_clone(self, repo_path: str, remote: str):
378383
"""Perform full repository clone"""
379384
self.logger.info(f"Performing full clone for repo {remote}...")
380-
await run_shell_command(
381-
["git", "clone", "--no-tags", "--single-branch", remote, "."], cwd=repo_path
382-
)
385+
base_cmd = ["git", "clone", "--no-tags", "--single-branch"]
386+
try:
387+
await run_shell_command([*base_cmd, f"{remote}.git", "."], cwd=repo_path)
388+
except Exception:
389+
self.logger.warning(
390+
f"Clone with .git suffix failed, falling back to bare URL: {remote}"
391+
)
392+
await run_shell_command([*base_cmd, remote, "."], cwd=repo_path)
383393
self.logger.info(f"Successfully completed full clone of repository: {remote}")
384394

385395
async def has_default_branch_changed(self, remote: str, saved_branch: str | None) -> bool:

0 commit comments

Comments
 (0)