diff options
author | The Bundler Bot <bot@bundler.io> | 2017-06-01 06:09:42 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-01 23:55:32 -0500 |
commit | 3131fa36e2223010143a434c24779dd6e983e788 (patch) | |
tree | 669d4bcee163181fc44dee0e7cd26ec983b0be8c | |
parent | c7c05b8bfaf9069926bba068393d9428248e2101 (diff) | |
download | bundler-3131fa36e2223010143a434c24779dd6e983e788.tar.gz |
Auto merge of #5680 - bundler:seg-git-force-no-git-ops, r=segiddins
Allow bundle install --force to work with git specs
This allows `bundle install --force` to work when the gemfile includes a git spec, previously it would error nonsensically. This happened because sources needed to be `remote!`ed for installation to succeed, and this wouldn't happen when `--force` was called with no other changes to the gemfile.
Closes #5678
(cherry picked from commit 7f1411cdb3279c25e8e8f2a8e3c1f8acf3dbe8f2)
-rw-r--r-- | lib/bundler/installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 2 | ||||
-rw-r--r-- | spec/install/force_spec.rb | 31 |
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index cbfdddeaf7..a1d864e67d 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -212,7 +212,7 @@ module Bundler end def resolve_if_need(options) - if !options["update"] && !options[:inline] && Bundler.default_lockfile.file? + if !options["update"] && !options[:inline] && !options["force"] && Bundler.default_lockfile.file? local = Bundler.ui.silence do begin tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 0732432ba2..c05d7a5afa 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -3,7 +3,7 @@ require "shellwords" require "tempfile" module Bundler class Source - class Git < Path + class Git class GitNotInstalledError < GitError def initialize msg = String.new diff --git a/spec/install/force_spec.rb b/spec/install/force_spec.rb index 6d852b3bf1..dc4956a7ae 100644 --- a/spec/install/force_spec.rb +++ b/spec/install/force_spec.rb @@ -32,5 +32,36 @@ RSpec.describe "bundle install" do expect(out).to include "Installing rack 1.0.0" expect(the_bundle).to include_gems "rack 1.0.0" end + + context "with a git gem" do + let!(:ref) { build_git("foo", "1.0").ref_for("HEAD", 11) } + + before do + gemfile <<-G + gem "foo", :git => "#{lib_path("foo-1.0")}" + G + end + + it "re-installs installed gems" do + foo_lib = default_bundle_path("bundler/gems/foo-1.0-#{ref}/lib/foo.rb") + + bundle! "install" + foo_lib.open("w") {|f| f.write("blah blah blah") } + bundle! "install --force" + + expect(out).to include "Using bundler" + expect(out).to include "Using foo 1.0 from #{lib_path("foo-1.0")} (at master@#{ref[0, 7]})" + expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n") + expect(the_bundle).to include_gems "foo 1.0" + end + + it "works on first bundle install" do + bundle! "install --force" + + expect(out).to include "Using bundler" + expect(out).to include "Using foo 1.0 from #{lib_path("foo-1.0")} (at master@#{ref[0, 7]})" + expect(the_bundle).to include_gems "foo 1.0" + end + end end end |