1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Changing 'rails new' --master to be --main

Renaming test containing flag

Updating other test referencing master branch

Add notice that --master is deprecated, but still working the same as --main

Only set @main if it's nil

Making warn wildcard

I think a hidden aliaes would be just as good

Improving description & fixing rubocop error

Forgot comma

Deprecation warning was kind of hard - so just doing alias for now

rubocop -a
This commit is contained in:
Mike Rogers 2021-01-19 21:07:32 +00:00
parent 077c66d5d6
commit 83f2f9fd24
5 changed files with 15 additions and 7 deletions

View file

@ -97,7 +97,7 @@ module Rails
class_option :edge, type: :boolean, default: false, class_option :edge, type: :boolean, default: false,
desc: "Set up the #{name} with Gemfile pointing to Rails repository" desc: "Set up the #{name} with Gemfile pointing to Rails repository"
class_option :master, type: :boolean, default: false, class_option :main, type: :boolean, default: false, aliases: "--master",
desc: "Set up the #{name} with Gemfile pointing to Rails repository main branch" desc: "Set up the #{name} with Gemfile pointing to Rails repository main branch"
class_option :rc, type: :string, default: nil, class_option :rc, type: :string, default: nil,
@ -279,7 +279,7 @@ module Rails
[ [
GemfileEntry.github("rails", "rails/rails", "main") GemfileEntry.github("rails", "rails/rails", "main")
] ]
elsif options.master? elsif options.main?
[ [
GemfileEntry.github("rails", "rails/rails", "main") GemfileEntry.github("rails", "rails/rails", "main")
] ]

View file

@ -46,7 +46,7 @@ end
group :development do group :development do
<%- unless options.api? || options.skip_dev_gems? -%> <%- unless options.api? || options.skip_dev_gems? -%>
# Access an interactive console on exception pages or by calling 'console' anywhere in the code. # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
<%- if options.dev? || options.edge? || options.master? -%> <%- if options.dev? || options.edge? || options.main? -%>
gem 'web-console', github: 'rails/web-console' gem 'web-console', github: 'rails/web-console'
<%- else -%> <%- else -%>
gem 'web-console', '>= 4.1.0' gem 'web-console', '>= 4.1.0'

View file

@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
<%= '# ' if options.dev? || options.edge? || options.master? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>" <%= '# ' if options.dev? || options.edge? || options.main? -%>spec.add_dependency "rails", "<%= Array(rails_version_specifier).join('", "') %>"
end end

View file

@ -2,7 +2,7 @@ source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" } git_source(:github) { |repo| "https://github.com/#{repo}.git" }
<% if options[:skip_gemspec] -%> <% if options[:skip_gemspec] -%>
<%= '# ' if options.dev? || options.edge? || options.master? -%>gem 'rails', '<%= Array(rails_version_specifier).join("', '") %>' <%= '# ' if options.dev? || options.edge? || options.main? -%>gem 'rails', '<%= Array(rails_version_specifier).join("', '") %>'
<% else -%> <% else -%>
# Specify your gem's dependencies in <%= name %>.gemspec. # Specify your gem's dependencies in <%= name %>.gemspec.
gemspec gemspec

View file

@ -809,8 +809,8 @@ class AppGeneratorTest < Rails::Generators::TestCase
end end
end end
def test_web_console_with_master_option def test_web_console_with_main_option
run_generator [destination_root, "--master"] run_generator [destination_root, "--main"]
assert_file "Gemfile" do |content| assert_file "Gemfile" do |content|
assert_match(/gem 'web-console',\s+github: 'rails\/web-console'/, content) assert_match(/gem 'web-console',\s+github: 'rails\/web-console'/, content)
@ -868,6 +868,14 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']main["']$} assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']main["']$}
end end
def test_main_option
generator([destination_root], main: true, skip_webpack_install: true)
run_generator_instance
assert_equal 1, @bundle_commands.count("install")
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']main["']$}
end
def test_spring def test_spring
jruby_skip "spring doesn't run on JRuby" jruby_skip "spring doesn't run on JRuby"