diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2012-04-01 19:29:29 +0200 |
---|---|---|
committer | Terence Lee <hone02@gmail.com> | 2012-07-17 04:57:23 -0500 |
commit | 2ef30d66c88019c9969c0e7c7a7d01e3bc9e86a9 (patch) | |
tree | 8bbe3574d46f3aea5c93c99c1b91fc245ca43151 | |
parent | 8df2ae5f622228c05742c6de17cac899fcd3a7d7 (diff) | |
download | bundler-2ef30d66c88019c9969c0e7c7a7d01e3bc9e86a9.tar.gz |
Make locking the Gemfile optional on $ bundle check
Currently `bundle check` locks the Gemfile. According to @indirect this
behaviour is intentional (see
https://twitter.com/#!/indirect/status/186493694013210624).
I am working on a CLI monitoring tool that makes it easier to work with
cross-repository changes on projects that are split up into several
repositories.
This tool is supposed to display status information such as out-of-date
bundler Gemfiles etc. To do so it watches the filesystem and queries for
information on demand. Using `bundle check` to do so currently leads to
highly confusing side-effects because suddenly the git working directory
might be dirty - having changed the Gemfile.lock - because `bundle
check` has been run in the background.
This patch adds a boolean method option `--[no-]lock` to `bundle check`
that defaults to `true` in order to not change the current behaviour but
make it possible for users to turn it off.
Sidenote: apparently the same behaviour also applies to `bundle show`.
Am I the only one who finds this highly confusing?
-rw-r--r-- | lib/bundler/cli.rb | 4 | ||||
-rw-r--r-- | spec/other/check_spec.rb | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 1dd75d6345..de5c5923af 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -94,6 +94,8 @@ module Bundler "Use the specified gemfile instead of Gemfile" method_option "path", :type => :string, :banner => "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine" + method_option "lock", :type => :boolean, :default => true, :banner => + "Lock the Gemfile" def check ENV['BUNDLE_GEMFILE'] = File.expand_path(options[:gemfile]) if options[:gemfile] @@ -117,7 +119,7 @@ module Bundler Bundler.ui.error "This bundle has been frozen, but there is no Gemfile.lock present" exit 1 else - Bundler.load.lock + Bundler.load.lock if options[:lock] Bundler.ui.info "The Gemfile's dependencies are satisfied" end end diff --git a/spec/other/check_spec.rb b/spec/other/check_spec.rb index d6ff6d337b..8a01e3a3b6 100644 --- a/spec/other/check_spec.rb +++ b/spec/other/check_spec.rb @@ -23,7 +23,7 @@ describe "bundle check" do out.should == "The Gemfile's dependencies are satisfied" end - it "creates a Gemfile.lock if one did not exist" do + it "creates a Gemfile.lock by default if one did not exist" do install_gemfile <<-G source "file://#{gem_repo1}" gem "rails" @@ -36,6 +36,19 @@ describe "bundle check" do bundled_app("Gemfile.lock").should exist end + it "does not create a Gemfile.lock if --no-lock was passed" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rails" + G + + FileUtils.rm("Gemfile.lock") + + bundle "check --no-lock" + + bundled_app("Gemfile.lock").should_not exist + end + it "prints a generic error if the missing gems are unresolvable" do system_gems ["rails-2.3.2"] |