diff options
author | David RodrÃguez <[email protected]> | 2023-02-08 21:03:35 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-02-21 19:28:12 +0900 |
commit | e7bf85961d43e5679946abd3cd0de59278582309 (patch) | |
tree | 8a95703d4433598c3becca0e0d05650ca1dff948 | |
parent | 9b6d421ff44c7ca2810ccb1ed7f1d968c9afc395 (diff) |
[rubygems/rubygems] Restore better error message when locked ref does not exist
https://github.com/rubygems/rubygems/commit/c8e024359f
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7345
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 10 | ||||
-rw-r--r-- | spec/bundler/lock/git_spec.rb | 27 |
2 files changed, 33 insertions, 4 deletions
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 2a7c8473f5..2a2b48053a 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -139,8 +139,8 @@ module Bundler out, err, status = capture(command, path) return out if status.success? - if err.include?("couldn't find remote ref") - raise MissingGitRevisionError.new(command_with_no_credentials, path, explicit_ref, credential_filtered_uri) + if err.include?("couldn't find remote ref") || err.include?("not our ref") + raise MissingGitRevisionError.new(command_with_no_credentials, path, commit || explicit_ref, credential_filtered_uri) else raise GitCommandError.new(command_with_no_credentials, path, err) end @@ -186,8 +186,6 @@ module Bundler end def refspec - commit = pinned_to_full_sha? ? ref : @revision - if commit @commit_ref = "refs/#{commit}-sha" return "#{commit}:#{@commit_ref}" @@ -206,6 +204,10 @@ module Bundler "#{reference}:#{reference}" end + def commit + @commit ||= pinned_to_full_sha? ? ref : @revision + end + def fully_qualified_ref if branch "refs/heads/#{branch}" diff --git a/spec/bundler/lock/git_spec.rb b/spec/bundler/lock/git_spec.rb index a633bd546e..1c1f6fa93d 100644 --- a/spec/bundler/lock/git_spec.rb +++ b/spec/bundler/lock/git_spec.rb @@ -33,6 +33,33 @@ RSpec.describe "bundle lock with git gems" do expect(err).to include("Revision bad does not exist in the repository") end + it "prints a proper error when installing a Gemfile with a locked ref that does not exist" do + lockfile <<~L + GIT + remote: #{lib_path("foo-1.0")} + revision: #{"a" * 40} + specs: + foo (1.0) + + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "install", :raise_on_error => false + + expect(err).to include("Revision #{"a" * 40} does not exist in the repository") + end + it "locks a git source to the current ref" do update_git "foo" bundle :install |