diff options
author | Ellen Keal <[email protected]> | 2024-05-10 15:26:41 -0500 |
---|---|---|
committer | git <[email protected]> | 2024-05-22 06:01:50 +0000 |
commit | ec9de0c4717b2942edba560b510a170f812a2f2c (patch) | |
tree | 8474b5998dcb4475497b2aac472793687f395434 | |
parent | 1e08a9f0e9058186db18f29efc6458c00f10a856 (diff) |
[rubygems/rubygems] fix for gems not downloading from git via http
https://github.com/rubygems/rubygems/commit/592a2fcd54
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 8 | ||||
-rw-r--r-- | spec/bundler/bundler/source/git/git_proxy_spec.rb | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 645851286c..f89e465c07 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -181,6 +181,14 @@ module Bundler if err.include?("Could not find remote branch") raise MissingGitRevisionError.new(command_with_no_credentials, nil, explicit_ref, credential_filtered_uri) + elsif err.include?("dumb http transport does not support shallow capabilities") + idx = command.index("--depth") + if idx + command.delete_at(idx) + command.delete_at(idx) + err += "Retrying without --depth argument." + end + raise GitCommandError.new(command_with_no_credentials, path, err) else raise GitCommandError.new(command_with_no_credentials, path, err) end diff --git a/spec/bundler/bundler/source/git/git_proxy_spec.rb b/spec/bundler/bundler/source/git/git_proxy_spec.rb index 1450316d59..f7c883eed4 100644 --- a/spec/bundler/bundler/source/git/git_proxy_spec.rb +++ b/spec/bundler/bundler/source/git/git_proxy_spec.rb @@ -197,4 +197,18 @@ RSpec.describe Bundler::Source::Git::GitProxy do expect(Pathname.new(bundled_app("canary"))).not_to exist end + + context "URI is HTTP" do + let(:uri) { "http://github.com/rubygems/rubygems.git" } + let(:without_depth_arguments) { ["clone", "--bare", "--no-hardlinks", "--quiet", "--no-tags", "--single-branch"] } + let(:fail_clone_result) { double(Process::Status, success?: false) } + + it "retries without --depth when git url is http and fails" do + allow(git_proxy).to receive(:git_local).with("--version").and_return("git version 2.14.0") + allow(git_proxy).to receive(:capture).with([*base_clone_args, "--", uri, path.to_s], nil).and_return(["", "dumb http transport does not support shallow capabilities", fail_clone_result]) + expect(git_proxy).to receive(:capture).with([*without_depth_arguments, "--", uri, path.to_s], nil).and_return(["", "", clone_result]) + + subject.checkout + end + end end |