summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-06-01 06:09:42 +0000
committerThe Bundler Bot <bot@bundler.io>2017-06-01 06:09:42 +0000
commit7f1411cdb3279c25e8e8f2a8e3c1f8acf3dbe8f2 (patch)
tree9ca560d2b2ceeb5c12bb6078da1763d96ce15ea4
parent9f041743debac51bea183405e3924ec1688a3660 (diff)
parent5161573850d621f002c50cddcbc1ca2d3980a519 (diff)
downloadbundler-7f1411cdb3279c25e8e8f2a8e3c1f8acf3dbe8f2.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
-rw-r--r--lib/bundler/installer.rb2
-rw-r--r--lib/bundler/source/git/git_proxy.rb2
-rw-r--r--spec/install/force_spec.rb31
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index a3e8d3c62d..efad66e202 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -215,7 +215,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 e5edb0a9c9..d7236a5d7e 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 2ac7f57399..2bc300597d 100644
--- a/spec/install/force_spec.rb
+++ b/spec/install/force_spec.rb
@@ -31,5 +31,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