From c660a2dcc5fbd41a143741e4bd303fb9df123ca7 Mon Sep 17 00:00:00 2001 From: The Bundler Bot Date: Sun, 30 Apr 2017 09:04:01 +0000 Subject: Auto merge of #5622 - bundler:seg-shortref-display, r=indirect [Git] Only shorten refs if they are SHAs Closes #5620 (cherry picked from commit fea23637886c1b1bde471c98344b8844f82e60ce) --- lib/bundler/source/git.rb | 8 ++++++-- spec/install/git_spec.rb | 22 ++++++++++++++++++++++ spec/support/builders.rb | 3 ++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index da48d64439..b3e218e390 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -61,8 +61,12 @@ module Bundler def to_s at = if local? path - elsif options["ref"] - shortref_for_display(options["ref"]) + elsif user_ref = options["ref"] + if ref =~ /\A[a-z0-9]{4,}\z/i + shortref_for_display(user_ref) + else + user_ref + end else ref end diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index a555822012..04f2380b45 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -15,6 +15,28 @@ RSpec.describe "bundle install" do expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}" end + it "displays the ref of the gem repository when using branch~num as a ref" do + build_git "foo", "1.0", :path => lib_path("foo") + rev = revision_for(lib_path("foo"))[0..6] + update_git "foo", "2.0", :path => lib_path("foo"), :gemspec => true + rev2 = revision_for(lib_path("foo"))[0..6] + update_git "foo", "3.0", :path => lib_path("foo"), :gemspec => true + + install_gemfile! <<-G + gem "foo", :git => "#{lib_path("foo")}", :ref => "master~2" + G + + bundle! :install + expect(out).to include("Using foo 1.0 from #{lib_path("foo")} (at master~2@#{rev})") + expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}" + + update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true + + bundle! :update + expect(out).to include("Using foo 2.0 (was 1.0) from #{lib_path("foo")} (at master~2@#{rev2})") + expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}" + end + it "should check out git repos that are missing but not being installed" do build_git "foo" diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 75aed0e7ee..28a271998e 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -659,6 +659,7 @@ module Spec def _build(options) libpath = options[:path] || _default_path update_gemspec = options[:gemspec] || false + source = options[:source] || "git@#{libpath}" Dir.chdir(libpath) do silently "git checkout master" @@ -684,7 +685,7 @@ module Spec _default_files.keys.each do |path| _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'" end - super(options.merge(:path => libpath, :gemspec => update_gemspec)) + super(options.merge(:path => libpath, :gemspec => update_gemspec, :source => source)) `git add *` `git commit -m "BUMP"` end -- cgit v1.2.1