summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-04-22 03:42:37 +0000
committerThe Bundler Bot <bot@bundler.io>2017-04-22 03:42:37 +0000
commit334b901de575ca4b6b88e164106e2a52f4f4bff9 (patch)
tree6ccf6ac5181bb395d3cdda75f8d3ff5399072232
parentf441bc85855b4778f80989f17cf7ae3a55a2d766 (diff)
parent9be3a304359cd81956c14f33ab905084a128d866 (diff)
downloadbundler-334b901de575ca4b6b88e164106e2a52f4f4bff9.tar.gz
Auto merge of #5602 - alextaylor000:issue-5423, r=segiddins
Ensure pre-existing Git caches are updated from remote sources This will be my first contribution to Bundler. Thanks for the amazing dev setup guides! This fixes issue #5423 where Git sources would not be updated if they were already cached in `vendor/cache`. When we build a Git source from Gemfile.lock, we store the revision listed in the lockfile. However, when unlocking the source for an update, we don't clear that revision, and the update proceeds to grab the stale version from `vendor/cache`. Interestingly, this behaviour only occurs when updating a specific gem, i.e. `bundle update timecop`. This bug isn't present when doing a global `bundle update`, possibly because of the differences in how we build up the Definition between the two methods. Closes #5423.
-rw-r--r--lib/bundler/source/git.rb3
-rw-r--r--spec/cache/git_spec.rb27
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 62f38a3a8d..da48d64439 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -105,6 +105,8 @@ module Bundler
def unlock!
git_proxy.revision = nil
+ options["revision"] = nil
+
@unlocked = true
end
@@ -147,7 +149,6 @@ module Bundler
changed
end
- # TODO: cache git specs
def specs(*)
set_local!(app_cache_path) if has_app_cache? && !local?
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index b256c8d90f..31b3816a3b 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -93,6 +93,33 @@ end
expect(out).to eq("CACHE")
end
+ it "tracks updates when specifying the gem" do
+ git = build_git "foo"
+ old_ref = git.ref_for("master", 11)
+
+ install_gemfile <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+
+ bundle "#{cmd} --all"
+
+ update_git "foo" do |s|
+ s.write "lib/foo.rb", "puts :CACHE"
+ end
+
+ ref = git.ref_for("master", 11)
+ expect(ref).not_to eq(old_ref)
+
+ bundle "update foo"
+
+ expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
+ expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
+
+ FileUtils.rm_rf lib_path("foo-1.0")
+ run "require 'foo'"
+ expect(out).to eq("CACHE")
+ end
+
it "uses the local repository to generate the cache" do
git = build_git "foo"
ref = git.ref_for("master", 11)