Skip to content

Retry git fetch without --depth for dumb HTTP transport#9405

Merged
hsbt merged 2 commits intomasterfrom
fix-gh-9049
Mar 17, 2026
Merged

Retry git fetch without --depth for dumb HTTP transport#9405
hsbt merged 2 commits intomasterfrom
fix-gh-9049

Conversation

@hsbt
Copy link
Member

@hsbt hsbt commented Mar 17, 2026

What was the end-user or developer problem that led to this PR?

Dumb HTTP git servers do not support shallow capabilities. Bundler already retries git clone without --depth when this fails (#7649), but the same fallback was missing for git fetch. This causes bundle install to fail when fetching updates from a dumb HTTP git source.

Fixes #9001
Fixes #9049

Make sure the following tasks are checked

hsbt and others added 2 commits March 17, 2026 15:21
Dumb HTTP git servers do not support shallow capabilities, causing
`git fetch --depth` to fail. The retry-without-depth logic already
existed for clone but was missing for fetch.

Also refactor clone_needs_extra_fetch? to rebuild the command via
helper methods instead of using fragile delete_at index manipulation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The predicate checks whether depth is set, which applies equally to
clone and fetch contexts. Rename to shallow? so the intent reads
naturally in both places.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 17, 2026 06:33
@hsbt hsbt mentioned this pull request Mar 17, 2026
4 tasks
Copy link
Contributor

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

Adds a missing shallow-fetch fallback for “dumb HTTP” git servers by retrying git fetch without --depth when the initial shallow fetch fails, matching existing behavior for git clone.

Changes:

  • Refactors git command assembly into fetch_command / clone_command helpers.
  • Extends the existing shallow-clone fallback to also apply to shallow fetches (retry without --depth).
  • Adds/updates specs to cover the new fetch fallback and clarifies the clone fallback spec wording.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
bundler/lib/bundler/source/git/git_proxy.rb Implements the fetch retry fallback by rebuilding the fetch command without depth args on failure; refactors command construction; renames full_clone? to shallow?.
bundler/spec/bundler/source/git/git_proxy_spec.rb Updates clone retry spec naming and adds a new spec ensuring fetch is retried without --depth when the shallow-capabilities error occurs.

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

Comment on lines +169 to 174
if shallow?
args -= depth_args
command = fetch_command(args)
command_with_no_credentials = check_allowed(command)
end
raise GitCommandError.new(command_with_no_credentials, path, err)
Comment on lines +198 to 203
if shallow?
clone_args -= depth_args
command = clone_command(clone_args)
command_with_no_credentials = check_allowed(command)

err += "Retrying without --depth argument."
end
raise GitCommandError.new(command_with_no_credentials, path, err)
@hsbt hsbt merged commit cb6fbe3 into master Mar 17, 2026
118 of 120 checks passed
@hsbt hsbt deleted the fix-gh-9049 branch March 17, 2026 07:44
hsbt added a commit that referenced this pull request Mar 25, 2026
Retry git fetch without --depth for dumb HTTP transport

(cherry picked from commit cb6fbe3)
hsbt added a commit that referenced this pull request Mar 25, 2026
Retry git fetch without --depth for dumb HTTP transport

(cherry picked from commit cb6fbe3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Picking up from #7547 -- dumb (http) git repo support broken

2 participants