Skip to content

Commit

Permalink
Merge pull request #27632 from dixpac/repo_initialize
Browse files Browse the repository at this point in the history
Initalize git repo when creatin new rails app
  • Loading branch information
rafaelfranca committed Jan 18, 2017
2 parents 8d00967 + 8989a50 commit aa70abb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Initialize git repo when generating new app, if option `--skip-git`
is not provided.

*Dino Maric*

* Install Byebug gem as default in Windows (mingw and x64_mingw) platform.

*Junichi Ito*
Expand Down
7 changes: 7 additions & 0 deletions railties/lib/rails/generators/rails/app/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ def gitignore
template "gitignore", ".gitignore"
end

def version_control
unless options[:skip_git]
run "git init"
end
end

def app
directory "app"

Expand Down Expand Up @@ -205,6 +211,7 @@ def create_root_files
build(:configru)
build(:gitignore) unless options[:skip_git]
build(:gemfile) unless options[:skip_gemfile]
build(:version_control)
end

def create_app_files
Expand Down
9 changes: 7 additions & 2 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,11 @@ def test_gitignore_when_non_sqlite3_db
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(
Expand Down Expand Up @@ -777,7 +782,7 @@ def test_after_bundle_callback
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}"
Expand All @@ -792,7 +797,7 @@ def test_after_bundle_callback
end
end

assert_equal 3, @sequence_step
assert_equal 4, @sequence_step
end

private
Expand Down
1 change: 1 addition & 0 deletions railties/test/generators/shared_generator_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def test_skip_bundle
def test_skip_git
run_generator [destination_root, "--skip-git", "--full"]
assert_no_file(".gitignore")
assert_no_directory(".git")
end

def test_skip_keeps
Expand Down

0 comments on commit aa70abb

Please sign in to comment.