From 46d1cc90be94307f313a3ab384bd176a5b7f58b3 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Fri, 18 Dec 2015 18:02:21 +1030 Subject: Allow normal version updates within a release series We originally chose to apply very strict versioning on the `rails` entry in the Gemfile, because our future versioning policy was not strongly defined. Now it is, and our policy is very much designed on the expectation that people will regularly update to the latest patch level in their release series... so we should encourage that. Of course, Gemfile.lock will do its job and prevent unplanned updates, just as it does for every other gem in the bundle... but if you run `bundle update`, we want to get you the latest bug/security fixes without requiring a manual edit of the Gemfile entry. Our current version could be a few different shapes, so it takes a bit of work to find the right specifier, but in principle, we match anything of the form x.y.*, where x.y matches our current release series. --- railties/lib/rails/generators/app_base.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/generators/app_base.rb') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 9036966d42..8b6295939e 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -232,11 +232,25 @@ module Rails ] + dev_edge_common else [GemfileEntry.version('rails', - Rails::VERSION::STRING, + rails_version_specifier, "Bundle edge Rails instead: gem 'rails', github: 'rails/rails'")] end end + def rails_version_specifier(gem_version = Rails.gem_version) + if gem_version.prerelease? + next_series = gem_version + next_series = next_series.bump while next_series.segments.size > 2 + + [">= #{gem_version}", "< #{next_series}"] + elsif gem_version.segments.size == 3 + "~> #{gem_version}" + else + patch = gem_version.segments[0, 3].join(".") + ["~> #{patch}", ">= #{gem_version}"] + end + end + def gem_for_database # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql ) case options[:database] -- cgit v1.2.3