Retry git fetch without --depth for dumb HTTP transport#9405
Merged
Conversation
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>
4 tasks
Contributor
There was a problem hiding this comment.
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_commandhelpers. - 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
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 clonewithout--depthwhen this fails (#7649), but the same fallback was missing forgit fetch. This causesbundle installto fail when fetching updates from a dumb HTTP git source.Fixes #9001
Fixes #9049
Make sure the following tasks are checked