Skip to content

fix(repo-brancher): use --deepen and --unshallow#5014

Open
petr-muller wants to merge 2 commits intoopenshift:mainfrom
petr-muller:fast-forwarder-speedup-1
Open

fix(repo-brancher): use --deepen and --unshallow#5014
petr-muller wants to merge 2 commits intoopenshift:mainfrom
petr-muller:fast-forwarder-speedup-1

Conversation

@petr-muller
Copy link
Member

@petr-muller petr-muller commented Mar 15, 2026

  • Using --deepen avoids re-fetching revisions when doing the imcrements.
  • I also 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 that limit by using --unshallow just like private-org-sync does

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>
Copilot AI review requested due to automatic review settings March 15, 2026 03:03
@openshift-ci-robot
Copy link
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f60a7773-bce1-4057-a29a-f578a7024c05

📥 Commits

Reviewing files that changed from the base of the PR and between 05494d0 and 0a59a25.

📒 Files selected for processing (1)
  • cmd/repo-brancher/main.go

Walkthrough

Modified repository branching logic to support deeper Git history fetching. Expanded the deepening loop to iterate depth 1-9 (previously 1-8), added a new fetchUnshallow helper function, changed fetchDeeper to use git fetch --deepen instead of git fetch --depth, and added explicit handling at depth 9 to attempt unshallowing as a final progressive fetch strategy before marking configuration as failed.

Changes

Cohort / File(s) Summary
Deepening Loop Expansion
cmd/repo-brancher/main.go
Extended loop from depth 1-8 to 1-9 inclusive; added depth 9 handling to log failure after unshallowing attempt and mark configuration as failed; added warning message at depth 8 about insufficient progressive deepening.
Progressive Fetch Strategy Refactoring
cmd/repo-brancher/main.go
Changed fetchDeeper command from git fetch --depth to git fetch --deepen; added new fetchUnshallow helper function to perform git fetch --unshallow; added conditional logic at depth 8 to invoke fetchUnshallow instead of continuing with fetchDeeper; updated error handling for failed unshallow attempts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: petr-muller
Once this PR has been reviewed and has the lgtm label, please assign deepsm007 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot requested a review from Prucek March 15, 2026 03:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --depth to git fetch --deepen.
  • Add an --unshallow fallback 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.

appendFailedConfig(configuration)
return nil
}
} else if err := fetchDeeper(logger, remote, gitCmd, repoInfo, int(math.Exp2(float64(depth)))); err != nil {
Comment on lines 244 to +245
func fetchDeeper(logger *logrus.Entry, remote *url.URL, gitCmd gitCmd, repoInfo *config.Info, depth int) error {
command := []string{"fetch", "--depth", strconv.Itoa(depth), remote.String(), repoInfo.Branch}
command := []string{"fetch", "--deepen", strconv.Itoa(depth), remote.String(), repoInfo.Branch}
Comment on lines +202 to +205
if depth == 8 {
logger.Warn("Progressive deepening was not enough, fetching full history...")
if err := fetchUnshallow(logger, remote, gitCmd, repoInfo); err != nil {
appendFailedConfig(configuration)
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 15, 2026

@petr-muller: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/breaking-changes 0a59a25 link false /test breaking-changes
ci/prow/integration 0a59a25 link true /test integration
ci/prow/checkconfig 0a59a25 link true /test checkconfig

Full PR test history. Your PR dashboard.

Details

Instructions 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.

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.

3 participants