Skip to content

Commit 8b5726a

Browse files
authored
fix: partial clone failure [DE-921] (#3970)
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 9918bfb commit 8b5726a

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
get_default_branch,
1818
get_remote_default_branch,
1919
get_repo_name,
20+
normalize_gerrit_remote,
2021
run_shell_command,
2122
)
2223

@@ -370,6 +371,7 @@ async def clone_batches_generator(
370371
error_message = None
371372
total_execution_time = 0.0
372373
remote = repository.url.removesuffix(".git")
374+
clone_remote = normalize_gerrit_remote(remote)
373375

374376
batch_info = CloneBatchInfo(
375377
repo_path=temp_repo_path,
@@ -382,10 +384,10 @@ async def clone_batches_generator(
382384
batch_start_time = time.time()
383385

384386
clone_with_batches = await self.determine_clone_strategy(
385-
temp_repo_path, remote, repository.branch, repository.last_processed_commit
387+
temp_repo_path, clone_remote, repository.branch, repository.last_processed_commit
386388
)
387389
if clone_with_batches:
388-
batch_depth = await self._calculate_batch_depth(temp_repo_path, remote)
390+
batch_depth = await self._calculate_batch_depth(temp_repo_path, clone_remote)
389391
await self._update_batch_info(
390392
batch_info, temp_repo_path, repository.last_processed_commit, clone_with_batches
391393
)

services/apps/git_integration/src/crowdgit/services/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313
from crowdgit.logger import logger
1414

1515

16+
def normalize_gerrit_remote(url: str) -> str:
17+
"""Rewrite Gerrit remote URLs to their Gitea equivalents for git clone/fetch operations.
18+
19+
Gerrit servers don't support the git shallow protocol extension (--deepen),
20+
causing HTTP 500 errors during incremental fetching. Where a Gitea mirror
21+
exists with full protocol support (e.g. opendev.org mirrors review.opendev.org),
22+
we rewrite the host so that shallow cloning works.
23+
24+
Only used for git operations, not for URLs persisted to the database or
25+
passed to other services.
26+
"""
27+
return url.replace("https://review.opendev.org", "https://opendev.org")
28+
29+
1630
def safe_decode(data: bytes) -> str:
1731
"""
1832
Safely decode bytes to string, handling various encodings that might be present in git output.

0 commit comments

Comments
 (0)