diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index f7ad6057b46b79..4a9f3731bd1f56 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -69,19 +69,7 @@ def eql?(other) def to_s begin - at = if local? - path - elsif user_ref = options["ref"] - if /\A[a-z0-9]{4,}\z/i.match?(ref) - shortref_for_display(user_ref) - else - user_ref - end - elsif ref - ref - else - current_branch - end + at = humanized_ref || current_branch rev = "at #{at}@#{shortref_for_display(revision)}" rescue GitError @@ -91,6 +79,10 @@ def to_s uri_with_specifiers([rev, glob_for_display]) end + def identifier + uri_with_specifiers([humanized_ref, cached_revision, glob_for_display]) + end + def uri_with_specifiers(specifiers) specifiers.compact! @@ -256,6 +248,20 @@ def local? private + def humanized_ref + if local? + path + elsif user_ref = options["ref"] + if /\A[a-z0-9]{4,}\z/i.match?(ref) + shortref_for_display(user_ref) + else + user_ref + end + elsif ref + ref + end + end + def serialize_gemspecs_in(destination) destination = destination.expand_path(Bundler.root) if destination.relative? Dir["#{destination}/#{@glob}"].each do |spec_path| diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index c96a78bc1cff22..910f96f4ab2aa7 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -30,6 +30,13 @@ expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1 end + it "does not write to cache on bundler/setup" do + cache_path = default_bundle_path.join("cache") + FileUtils.rm_rf(cache_path) + ruby "require 'bundler/setup'" + expect(cache_path).not_to exist + end + it "caches the git repo globally and properly uses the cached repo on the next invocation" do simulate_new_machine bundle "config set global_gem_cache true"