diff options
author | David RodrÃguez <[email protected]> | 2023-02-15 21:25:55 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-02-21 19:28:12 +0900 |
commit | a47e1328e662b5c095b560b842687ed1901fd7b1 (patch) | |
tree | e695b4f5a2b342697136f03c38a41dac869836e0 /spec/bundler | |
parent | b5eb9ebd5d4eef4ef2c1a4d32b70c17807b834bb (diff) |
[rubygems/rubygems] Give a better message when Gemfile branch does not exist
https://github.com/rubygems/rubygems/commit/cb4fc41cbc
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7345
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/bundler/source/git/git_proxy_spec.rb | 10 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/git_spec.rb | 11 |
2 files changed, 17 insertions, 4 deletions
diff --git a/spec/bundler/bundler/source/git/git_proxy_spec.rb b/spec/bundler/bundler/source/git/git_proxy_spec.rb index 841b8651e4..98d54015e7 100644 --- a/spec/bundler/bundler/source/git/git_proxy_spec.rb +++ b/spec/bundler/bundler/source/git/git_proxy_spec.rb @@ -6,13 +6,15 @@ RSpec.describe Bundler::Source::Git::GitProxy do let(:ref) { "HEAD" } let(:revision) { nil } let(:git_source) { nil } + let(:clone_result) { double(Process::Status, :success? => true) } + let(:base_clone_args) { ["clone", "--bare", "--no-hardlinks", "--quiet", "--no-tags", "--depth", "1", "--single-branch"] } subject { described_class.new(path, uri, ref, revision, git_source) } context "with configured credentials" do it "adds username and password to URI" do Bundler.settings.temporary(uri => "u:p") do allow(subject).to receive(:git).with("--version").and_return("git version 2.14.0") - expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--no-tags", "--depth", "1", "--single-branch", "--", "https://u:[email protected]/rubygems/rubygems.git", path.to_s) + expect(subject).to receive(:capture).with([*base_clone_args, "--", "https://u:[email protected]/rubygems/rubygems.git", path.to_s], nil).and_return(["", "", clone_result]) subject.checkout end end @@ -20,7 +22,7 @@ RSpec.describe Bundler::Source::Git::GitProxy do it "adds username and password to URI for host" do Bundler.settings.temporary("github.com" => "u:p") do allow(subject).to receive(:git).with("--version").and_return("git version 2.14.0") - expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--no-tags", "--depth", "1", "--single-branch", "--", "https://u:[email protected]/rubygems/rubygems.git", path.to_s) + expect(subject).to receive(:capture).with([*base_clone_args, "--", "https://u:[email protected]/rubygems/rubygems.git", path.to_s], nil).and_return(["", "", clone_result]) subject.checkout end end @@ -28,7 +30,7 @@ RSpec.describe Bundler::Source::Git::GitProxy do it "does not add username and password to mismatched URI" do Bundler.settings.temporary("https://u:[email protected]/rubygems/rubygems-mismatch.git" => "u:p") do allow(subject).to receive(:git).with("--version").and_return("git version 2.14.0") - expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--no-tags", "--depth", "1", "--single-branch", "--", uri, path.to_s) + expect(subject).to receive(:capture).with([*base_clone_args, "--", uri, path.to_s], nil).and_return(["", "", clone_result]) subject.checkout end end @@ -38,7 +40,7 @@ RSpec.describe Bundler::Source::Git::GitProxy do original = "https://orig:[email protected]/rubygems/rubygems.git" subject = described_class.new(Pathname("path"), original, "HEAD") allow(subject).to receive(:git).with("--version").and_return("git version 2.14.0") - expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--no-tags", "--depth", "1", "--single-branch", "--", original, path.to_s) + expect(subject).to receive(:capture).with([*base_clone_args, "--", original, path.to_s], nil).and_return(["", "", clone_result]) subject.checkout end end diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index b6ea32819b..e3be680d89 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -1144,6 +1144,17 @@ RSpec.describe "bundle install with git sources" do G expect(err).to include("Revision deadbeef does not exist in the repository") end + + it "gives a helpful error message when the remote branch no longer exists" do + build_git "foo" + + install_gemfile <<-G, :raise_on_error => false + source "#{file_uri_for(gem_repo1)}" + gem "foo", :git => "#{file_uri_for(lib_path("foo-1.0"))}", :branch => "deadbeef" + G + + expect(err).to include("Revision deadbeef does not exist in the repository") + end end describe "bundle install with deployment mode configured and git sources" do |