Skip to content

fix: repair git sync shallow pulls#2176

Merged
yohamta0 merged 2 commits into
mainfrom
fix/git-sync-shallow-pull
May 19, 2026
Merged

fix: repair git sync shallow pulls#2176
yohamta0 merged 2 commits into
mainfrom
fix/git-sync-shallow-pull

Conversation

@yohamta0
Copy link
Copy Markdown
Collaborator

@yohamta0 yohamta0 commented May 18, 2026

Summary

Repair git-sync pull failures for shallow internal repositories when the remote branch advances beyond the available local history.

Changes

  • Remove the extra depth-1 fetch before git-sync pull so go-git can fetch the history it needs in one pull operation.
  • Retry shallow pulls after deepening history when an existing internal clone is already missing parent commits.
  • Add regression tests for multi-commit shallow pulls and recovery after the old shallow fetch path.

Root Cause

Dagu cloned and fetched the git-sync repository with depth 1, then performed a separate pull. When the remote branch was more than one commit ahead, go-git could not walk the missing intermediate parent commits and returned object not found.

Related Issues

Reported by a user; no linked issue.

Checklist

  • Code follows the project style guidelines
  • Self-review of the code has been performed
  • Tests have been added or updated as needed
  • Documentation has been updated as needed
  • Changes have been tested locally

Testing

  • go test ./internal/gitsync ./internal/service/frontend/api/v1 -count=1

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dbada9b0-42a0-4812-a459-14e17e314f74

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR refactors GitClient's pull mechanism to handle shallow clone failures. Instead of checking remote HEAD upfront, Pull now uses context-aware pulling and automatically recovers broken shallow checkouts by deepening the repository and retrying on object-not-found errors.

Changes

Shallow repository recovery and pull refactoring

Layer / File(s) Summary
Shallow repair strategy constants and helpers
internal/gitsync/git.go
shallowRepairDepth constant enables deep fetching; pullWorktree, isShallow, and repairShallowHistory helpers implement the pull and shallow-state detection logic.
Pull method refactoring with shallow recovery logic
internal/gitsync/git.go
Pull removes remote HEAD lookup, performs context-aware pulling via helper, and on ErrObjectNotFound in shallow repos, runs repair fetch and retries the pull before returning the result.
Pull recovery tests and test infrastructure
internal/gitsync/git_test.go
Test imports expanded for context and go-git subpackages; initGitTestRepo and commitGitTestFile helpers create test repos; two test cases validate pull behavior on shallow clones and recovery after explicit fetch.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: repair git sync shallow pulls' clearly and concisely summarizes the main purpose of the changeset: fixing the shallow pull issue by adding repair logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description follows the required template with all essential sections completed: Summary, Changes, Related Issues, and Checklist are all present and properly filled out.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/git-sync-shallow-pull

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yohamta0
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0 yohamta0 merged commit 5d2aebb into main May 19, 2026
10 checks passed
@yohamta0 yohamta0 deleted the fix/git-sync-shallow-pull branch May 19, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant