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

Initalize git repo when creatin new rails app

* If `--skip-git` is not specified initalize git repo
 when creating new rails app
This commit is contained in:
dixpac 2017-01-10 14:58:28 +01:00
parent 242d7e1e03
commit 8989a5057b
4 changed files with 20 additions and 2 deletions

View file

@ -1,3 +1,8 @@
* Initialize git repo when generating new app, if option `--skip-git`
is not provided.
*Dino Maric*
* Don't generate HTML/ERB templates for scaffold controller with `--api` flag.
Fixes #27591.

View file

@ -53,6 +53,12 @@ module Rails
template "gitignore", ".gitignore"
end
def version_control
unless options[:skip_git]
run "git init"
end
end
def app
directory "app"
@ -205,6 +211,7 @@ module Rails
build(:configru)
build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile]
build(:version_control)
end
def create_app_files

View file

@ -731,6 +731,11 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
def test_version_control_initializes_git_repo
run_generator [destination_root]
assert_directory ".git"
end
def test_create_keeps
run_generator
folders_with_keep = %w(
@ -777,7 +782,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
template
end
sequence = ["install", "exec spring binstub --all", "echo ran after_bundle"]
sequence = ["git init", "install", "exec spring binstub --all", "echo ran after_bundle"]
@sequence_step ||= 0
ensure_bundler_first = -> command do
assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}"
@ -792,7 +797,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
assert_equal 3, @sequence_step
assert_equal 4, @sequence_step
end
private

View file

@ -109,6 +109,7 @@ module SharedGeneratorTests
def test_skip_git
run_generator [destination_root, "--skip-git", "--full"]
assert_no_file(".gitignore")
assert_no_directory(".git")
end
def test_skip_keeps