diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-04-28 11:56:05 +0200 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-04-28 11:56:05 +0200 |
commit | 3df81bc12f81a6b4f2c625ac16edfa4ad6b88049 (patch) | |
tree | 318dfddef92e525c86bc66836730c9bd997e9ff9 | |
parent | 86165f8037b1b1f0cdb3826abf0e65beb777adb0 (diff) | |
download | bundler-seg-shortref-display.tar.gz |
[Git] Only shorten refs if they are SHAsseg-shortref-display
-rw-r--r-- | lib/bundler/source/git.rb | 8 | ||||
-rw-r--r-- | spec/install/git_spec.rb | 22 |
2 files changed, 28 insertions, 2 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" |