summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuanitoFatas <katehuang0320@gmail.com>2015-11-12 14:50:19 +0800
committerJuanitoFatas <katehuang0320@gmail.com>2015-11-17 18:06:07 +0800
commitfa58101e30f3885a9b7cd3711bcffb5797cc524d (patch)
treed99d351672ea5396d02f4188ef4bc3ef236b40df
parentf787c664b4645fb44066b140b3b9afee542590c9 (diff)
downloadbundler-fa58101e30f3885a9b7cd3711bcffb5797cc524d.tar.gz
Add support for specify gems via --update option for `bundle lock` command
This commit adds the ability to specify gems in `bundle lock` command via `--update` option. After this commit, if no list is given: ``` bundle lock --update ``` will update all gems. Or update a list of specified gems: ``` bundle lock --update devise ominiauth ``` In this way, we can use lock command for specific gems without downloading any gem.
-rw-r--r--lib/bundler/cli.rb4
-rw-r--r--lib/bundler/cli/lock.rb10
-rw-r--r--spec/commands/lock_spec.rb8
3 files changed, 18 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 138ce5d7b5..55bf274596 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -399,8 +399,8 @@ module Bundler
end
desc "lock", "Creates a lockfile without installing"
- method_option "update", :type => :boolean, :default => false, :banner =>
- "ignore the existing lockfile"
+ method_option "update", :type => :array, :lazy_default => [], :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"
method_option "print", :type => :boolean, :default => false, :banner =>
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index 14c4203774..5a967165a3 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -16,8 +16,14 @@ module Bundler
ui = Bundler.ui
Bundler.ui = UI::Silent.new if print
- unlock = options[:update]
- definition = Bundler.definition(unlock)
+ gems = options[:update]
+
+ if gems && !gems.empty?
+ definition = Bundler.definition(:gems => gems)
+ else
+ definition = Bundler.definition(true)
+ end
+
definition.resolve_remotely! unless options[:local]
if print
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index 834f088703..f1379cc8ca 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -94,4 +94,12 @@ describe "bundle lock" do
expect(read_lockfile "lock").to eq(@lockfile)
expect { read_lockfile }.to raise_error(Errno::ENOENT)
end
+
+ it "update specific gems using --update" do
+ lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub("10.0.2", "10.0.1")
+
+ bundle "lock --update rails rake"
+
+ expect(read_lockfile).to eq(@lockfile)
+ end
end