fix(repo-brancher): use --deepen and --unshallow#5014
fix(repo-brancher): use --deepen and --unshallow#5014openshift-merge-bot[bot] merged 5 commits intoopenshift:mainfrom
--deepen and --unshallow#5014Conversation
Using `--deepen` avoids re-fetching revisions when doing the imcrements. Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
…ches I just discovered there is actually a limit for how deep does the tool try to go when trying to deepen the fetches to find the connected graph. Remove the limit by doing a full `--unshallow` fallback. Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
WalkthroughUpdated repo-brancher to extend retry depths to 1–9, change progressive fetches to use Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Pull request overview
Updates repo-brancher’s retry fetch strategy to progressively deepen a shallow clone using git fetch --deepen, with a final git fetch --unshallow fallback to handle cases where deepening still isn’t sufficient to push the new branch.
Changes:
- Switch retry fetches from
git fetch --depthtogit fetch --deepen. - Add an
--unshallowfallback after progressive deepening is exhausted. - Adjust retry loop bounds/message to accommodate the extra unshallow attempt.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
/retest-required |
|
/hold reasonable CodeRabbit review, will address |
Address review feedback: - Use Exp2(depth-1) instead of Exp2(depth) so cumulative depths match the old --depth absolute targets (2, 4, 8, 16, ..., 128). --deepen is incremental, so each call adds to the existing depth. - Rename `depth` parameter to `deepenBy` in fetchDeeper to clarify that --deepen takes an incremental value, not an absolute depth. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test pushBranch, fetchDeeper, and fetchUnshallow using mock gitCmd to verify correct command construction and error handling: - pushBranch returns retry=true on "too shallow" errors - fetchDeeper passes correct --deepen value - fetchUnshallow passes --unshallow flag Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates repo-brancher’s retry strategy for pushing new branches from a shallow clone by switching from repeated --depth fetches to progressive --deepen, and falling back to --unshallow to remove the deepening limit and fetch full history when necessary.
Changes:
- Replace progressive
git fetch --depth=Nretries withgit fetch --deepen N. - Add a final fallback to
git fetch --unshallowwhen progressive deepening isn’t sufficient. - Add unit tests for
pushBranch,fetchDeeper, andfetchUnshallow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/repo-brancher/main.go | Switches retry fetch behavior to --deepen and adds --unshallow fallback. |
| cmd/repo-brancher/main_test.go | Adds tests covering push retry behavior and the new fetch commands. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Addressed all review feedback:
Also added benchmark results to the PR description. /unhold |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/repo-brancher/main_test.go (1)
148-153: Consider validating full push arguments for consistency with other tests.The mock only checks that the first argument is
"push"but doesn't verify the remote URL or branch name are passed correctly. This is inconsistent withTestFetchDeeperandTestFetchUnshallowwhich validate the entire command string, and could miss bugs in argument construction.♻️ Suggested improvement
mockGit := func(_ *logrus.Entry, args ...string) error { - if args[0] != "push" { - t.Errorf("expected push command, got %v", args) + expected := fmt.Sprintf("push %s release-4.18:release-4.18", remote.String()) + got := strings.Join(args, " ") + if got != expected { + t.Errorf("expected command %q, got %q", expected, got) } return tc.gitErr }Note: Adjust the expected format to match the actual arguments
pushBranchpasses to git.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/repo-brancher/main_test.go` around lines 148 - 153, The mockGit in the test only asserts args[0]=="push"; update the mock used by Test (the anonymous mockGit function) to validate the full slice of arguments produced by pushBranch (e.g., verify the remote URL and branch ref/tip format) instead of just the first element, mirroring the stricter checks used in TestFetchDeeper/TestFetchUnshallow; locate the mockGit closure and replace the simple check with a comparison against the expected []string (constructed the same way the test uses pushBranch inputs) and call t.Errorf with the full args on mismatch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmd/repo-brancher/main_test.go`:
- Around line 148-153: The mockGit in the test only asserts args[0]=="push";
update the mock used by Test (the anonymous mockGit function) to validate the
full slice of arguments produced by pushBranch (e.g., verify the remote URL and
branch ref/tip format) instead of just the first element, mirroring the stricter
checks used in TestFetchDeeper/TestFetchUnshallow; locate the mockGit closure
and replace the simple check with a comparison against the expected []string
(constructed the same way the test uses pushBranch inputs) and call t.Errorf
with the full args on mismatch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bbad4b6e-ffae-4a95-a978-8a4861db316c
📒 Files selected for processing (1)
cmd/repo-brancher/main_test.go
|
Pipeline controller notification No second-stage tests were triggered for this PR. This can happen when:
Use |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: petr-muller, Prucek The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test images |
|
@petr-muller: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
c0b6d98
into
openshift:main
Summary
git fetch --depthtogit fetch --deepento avoid re-fetching already-downloaded revisions during progressive deepeningExp2(depth-1)instead ofExp2(depth)) so cumulative depths match the old--depthabsolute targets (2, 4, 8, 16, ..., 128)depthparameter todeepenByinfetchDeeperto clarify the incremental semantics--unshallowfallback (like private-org-sync) when progressive deepening is exhausted, removing the previous hard limit that caused failures on deeply diverged branchespushBranch,fetchDeeper, andfetchUnshallowBenchmark (20 repos, 2026-03-19)
Test repos: 5 with no release branch, 5 slightly behind (1-3 commits), 5 far behind (30-200 commits), 5 already synced.
Vanilla fails on repos 150+ commits behind —
--depth 128max is not enough. The--unshallowfallback in the modified binary handles these cases correctly.🤖 Generated with Claude Code