Skip to content

Commit b702709

Browse files
committed
Update git init when generating plugins
* Extract separate test, test with `--skip-git` * Move `version_control` beneath `gitignore` to match `AppBuilder` from 8989a50 * Add changelog entry
1 parent 71b6d72 commit b702709

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

railties/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* Run `git init` when generating plugins.
2+
3+
Opt out with `--skip-git`.
4+
5+
*OKURA Masafumi*
6+
17
* Add benchmark generator
28

39
Introduce benchmark generator to benchmark Rails applications.

railties/lib/rails/generators/rails/plugin/plugin_generator.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ def gitignore
5757
template "gitignore", ".gitignore"
5858
end
5959

60+
def version_control
61+
if !options[:skip_git] && !options[:pretend]
62+
run "git init", capture: options[:quiet], abort_on_failure: false
63+
end
64+
end
65+
6066
def lib
6167
template "lib/%namespaced_name%.rb"
6268
template "lib/tasks/%namespaced_name%_tasks.rake"
@@ -161,12 +167,6 @@ def gemfile_entry
161167
append_file gemfile_in_app_path, entry
162168
end
163169
end
164-
165-
def version_control
166-
if !options[:skip_git] && !options[:pretend]
167-
run "git init", capture: options[:quiet], abort_on_failure: false
168-
end
169-
end
170170
end
171171

172172
module Generators

railties/test/generators/plugin_generator_test.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_correct_file_in_lib_folder_of_camelcase_plugin_name
6464
end
6565

6666
def test_generating_without_options
67-
output = run_generator
67+
run_generator
6868
assert_file "README.md", /Bukkits/
6969
assert_no_file "config/routes.rb"
7070
assert_no_file "app/assets/config/bukkits_manifest.js"
@@ -79,7 +79,11 @@ def test_generating_without_options
7979
assert_file "test/bukkits_test.rb", /assert_kind_of Module, Bukkits/
8080
assert_file "bin/test"
8181
assert_no_file "bin/rails"
82-
assert_match(/run git init/, output)
82+
end
83+
84+
def test_initializes_git_repo
85+
run_generator
86+
assert_directory ".git"
8387
end
8488

8589
def test_generating_in_full_mode_with_almost_of_all_skip_options
@@ -607,6 +611,7 @@ def test_no_details_from_git_when_skip_git
607611
assert_match name, contents
608612
assert_match email, contents
609613
end
614+
assert_no_directory ".git"
610615
end
611616

612617
def test_skipping_useless_folders_generation_for_api_engines

0 commit comments

Comments
 (0)