Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Implicit lock preservation #3722

Merged
merged 5 commits into from
Jun 8, 2015
Merged

Conversation

indirect
Copy link
Member

@indirect indirect commented Jun 5, 2015

When either bundle check is run, or any application requires the bundler/setup file, Bundler will automatically check whether it is possible to lock the Bundle. During the lock process, Bundler updates the lock if the implicit locking changes the lock file.

Starting with the 1.10 release, Bundler includes a lockfile section named BUNDLED WITH that includes the version of Bundler that generated the lockfile. In order to minimize git churn, and guarantee that the lockfile will only be changed when the user runs an explicit Bundler command, Bundler will now only add or update the BUNDLED WITH section during commands where the user asks for changes to the lock. This includes, but is not limited to, install, update, lock, and package.

Running the check command or loading an application that uses Bundler will still now add or update the BUNDLED WITH section if, and only if, the lockfile has also changed for a different reason (such as a gem being updated).

Simply using an application, by running bundle exec commands or by running bin/rails and the like, will not change the lockfile. As a result, the intended workflow with the BUNDLED WITH section is now slightly different than it was before:

  1. When running bundle install, Bundler will update the version in the lockfile if newer than the version present.
  2. Then, check in the lockfile change, exactly as you would after running install to change any other gem version.
  3. Older versions of Bundler will not change the number in the lock, but will warn the user that they are out of date.

refs rubygems/bundler-features#80
refs #3697

@indirect
Copy link
Member Author

indirect commented Jun 5, 2015

@andremedeiros
Copy link
Member

LGTM. 🚢


def lockfiles_equal?(current, proposed, preserve_bundled_with)
if preserve_bundled_with
pattern = /\n\nBUNDLED WITH\n.*\n/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better as a constant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the parser constant for BUNDLED WITH, and also the Gem::Version::VERSION_PATTERN constant for the next line (and with \w+ before it instead of .*)

@TimMoore
Copy link
Contributor

TimMoore commented Jun 5, 2015

Makes sense 👍

it "does not change the lock" do
lockfile lock_with(Bundler::VERSION.succ)
bundle :check
lockfile_should_be lock_with(Bundler::VERSION.succ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please verify the warning is still printed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does at least make sense to me to print the warning here, but I feel like I would rather not warn on bundle check than add a third special case to the BUNDLED WITH code :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ironic after my last comment, but the existing behavior is my preferred one: the check command warns, but bundler/setup does not.

@parndt
Copy link
Contributor

parndt commented Jun 8, 2015

Thanks, @indirect !

@indirect indirect force-pushed the implicit_lock_preservation branch from 4e46bb0 to 61738bd Compare June 8, 2015 07:15
@indirect
Copy link
Member Author

indirect commented Jun 8, 2015

@segiddins there's your specs

indirect and others added 5 commits June 8, 2015 00:32
we want to avoid changing the lock just to add BUNDLED WITH unless the 
user is explicitly running a Bundler command; implicit locking should 
not alter the lockfile.
When either `bundle check` is run, or any application requires the 
`bundler/setup` file, Bundler will automatically check whether it is 
possible to lock the Bundle. During the lock process, Bundler updates 
the lock if the implicit locking changes the lock file.

Starting with the 1.10 release, Bundler includes a lockfile section 
named BUNDLED WITH that includes the version of Bundler that generated 
the lockfile. In order to minimize git churn, and guarantee that the 
lockfile will only be changed when the user runs an explicit Bundler 
command, Bundler will now only add or update the BUNDLED WITH section 
during commands where the user asks for changes to the lock. This 
includes, but is not limited to, `install`, `update`, `lock`, and 
`package`.

Running the `check` command or loading an application that uses Bundler 
will still now add or update the BUNDLED WITH section if, and only if,
the lockfile has also changed for a different reason (such as a gem 
being updated).

Simply using an application, by running  `bundle exec` commands or by 
running `bin/rails` and the like, will not change the lockfile. As a 
result, the intended workflow with the BUNDLED WITH section is now 
slightly different than it was before:

1. When running `bundle install`, Bundler will update the version in 
   the lockfile if newer than the version present.
2. Then, check in the lockfile change, exactly as you would after 
   running install to change any other gem version.
3. Older versions of Bundler will not change the number in the lock, 
   but will warn the user that they are out of date.

refs rubygems/bundler-features#80
refs #3697
@indirect indirect force-pushed the implicit_lock_preservation branch from 61738bd to 14c22c7 Compare June 8, 2015 07:32
@indirect
Copy link
Member Author

indirect commented Jun 8, 2015

Specs are green, so I'm merging this. Thanks for the review, @segiddins!

indirect added a commit that referenced this pull request Jun 8, 2015
@indirect indirect merged commit f9a5def into 1-10-stable Jun 8, 2015
@indirect indirect deleted the implicit_lock_preservation branch June 8, 2015 21:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants