safe_update
safe_update copied to clipboard
Feature suggestion: skip update on locked versions
Sometimes the gem will waste work because the Gemfile
has a version locked-down.
For example:
gem 'paper_trail', '~> 3.0'
-------------
OUTDATED GEM: paper_trail
Newest: 4.1.0.
Installed: 3.0.9.
Running `bundle update paper_trail`...
committing changes (message: 'update gem: paper_trail')...
-------------
Version 3.0.9 is the latest that matches '~>3.0'. My suggestions is to skip the update (hard to do because you'd need to check rubygems) and/or adjust the message so it doesn't say "committing changes" when there's nothing to commit (easier to do).
Had a think about this. Just recording thoughts for my own future reference. We could basically make a really simple crappy copy of bundler's gem
method, and do instance_eval
on the gemfile, and if the second param is a string, figure out if the version requirement it specifies is already met by the version we have installed.
Alternatively, we could introduce bundler as a dependency and use the stuff bundler's already built in Bundler::Dsl
to save us having to re-write the code ourselves. Will have a crack at implementing this later.
Yeah, I suppose it's best to use the actual bundler code but, failing that, you could borrow the twiddle-wakka operator logic. I don't see an issue with adding bundler as a dependency - it's going to be there already anyway.
side-note: pessimize could make a good combination with safe_update. I'm going to give it a whirl as well.
side-note 2: found someone's implementation but didn't try it.