summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-09-11 17:34:58 +0200
committerSamuel Giddins <segiddins@segiddins.me>2016-09-11 17:34:58 +0200
commit2316c6e092c5e591d49398ce3428ef8f9b865130 (patch)
treec0eda7a2462238f7cf1297ad7c67e880d519181c
parenteb20f97d8e52175cd2004159c5ee46dcc1f89d7e (diff)
downloadbundler-seg-lock-no-update.tar.gz
[Lock] Default to not updatingseg-lock-no-update
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/lock.rb9
-rw-r--r--spec/commands/lock_spec.rb32
-rw-r--r--spec/support/helpers.rb6
4 files changed, 38 insertions, 11 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 8b48be35d2..ee18767a73 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -441,7 +441,7 @@ module Bundler
end
desc "lock", "Creates a lockfile without installing"
- method_option "update", :type => :array, :lazy_default => [], :banner =>
+ method_option "update", :type => :array, :lazy_default => true, :banner =>
"ignore the existing lockfile, update all gems by default, or update list of given gems"
method_option "local", :type => :boolean, :default => false, :banner =>
"do not attempt to fetch remote gemspecs and use the local gem cache only"
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index a6a95f895c..d4256ad4b9 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -17,14 +17,11 @@ module Bundler
ui = Bundler.ui
Bundler.ui = UI::Silent.new if print
- gems = options[:update]
Bundler::Fetcher.disable_endpoint = options["full-index"]
- if gems && !gems.empty?
- definition = Bundler.definition(:gems => gems)
- else
- definition = Bundler.definition(true)
- end
+ update = options[:update]
+ update = { :gems => update } if update.is_a?(Array)
+ definition = Bundler.definition(update)
options["remove-platform"].each do |platform|
definition.remove_platform(platform)
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index fc605dc5a6..590d421ba0 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -10,9 +10,11 @@ describe "bundle lock" do
strip_lockfile bundled_app(file).read
end
+ let(:repo) { gem_repo1 }
+
before :each do
gemfile <<-G
- source "file://#{gem_repo1}"
+ source "file://#{repo}"
gem "rails"
gem "with_license"
gem "foo"
@@ -20,7 +22,7 @@ describe "bundle lock" do
@lockfile = strip_lockfile <<-L
GEM
- remote: file:#{gem_repo1}/
+ remote: file:#{repo}/
specs:
actionmailer (2.3.2)
activesupport (= 2.3.2)
@@ -77,7 +79,7 @@ describe "bundle lock" do
it "writes a lockfile when there is an outdated lockfile using --update" do
lockfile @lockfile.gsub("2.3.2", "2.3.1")
- bundle "lock --update"
+ bundle! "lock --update"
expect(read_lockfile).to eq(@lockfile)
end
@@ -223,4 +225,28 @@ describe "bundle lock" do
#{Bundler::VERSION}
G
end
+
+ context "when an update is available" do
+ let(:repo) { gem_repo2 }
+
+ before do
+ lockfile(@lockfile)
+ build_repo2 do
+ build_gem "foo", "2.0"
+ end
+ end
+
+ it "does not implicitly update" do
+ bundle! "lock"
+
+ expect(read_lockfile).to eq(@lockfile)
+ end
+
+ it "accounts for changes in the gemfile" do
+ gemfile gemfile.gsub('"foo"', '"foo", "2.0"')
+ bundle! "lock"
+
+ expect(read_lockfile).to eq(@lockfile.sub("foo (1.0)", "foo (2.0)").sub(/foo$/, "foo (= 2.0)"))
+ end
+ end
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index fe79604f30..b30c44d1cb 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -208,7 +208,11 @@ module Spec
end
def gemfile(*args)
- create_file("Gemfile", *args)
+ if args.empty?
+ File.open("Gemfile", "r", &:read)
+ else
+ create_file("Gemfile", *args)
+ end
end
def lockfile(*args)