summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2015-11-27 11:35:01 +0900
committerHomu <homu@barosl.com>2015-11-27 11:35:01 +0900
commit13157eb627f05f40c9dd8a2762decdc6d886ba55 (patch)
treebdb9d96ca88c852b9bbfa723820e171ffd440856
parente3124ff8de1a802c7e7c21e8be33aa0b68f9ea09 (diff)
parentfa58101e30f3885a9b7cd3711bcffb5797cc524d (diff)
downloadbundler-13157eb627f05f40c9dd8a2762decdc6d886ba55.tar.gz
Auto merge of #4105 - JuanitoFatas:feature/lock-takes-gems, r=indirect
[Lock] Add support for specify gems to `bundle lock` command This Pull Request adds the ability to specify gems in bundle lock command via command-line option, so that this is allowed: ``` bundle lock --gems devise ``` or ``` bundle lock --gems devise ominiauth ``` In this way, we can use lock command for specific gems without downloading any gem. Thanks!
-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