skip-git should not hit git commands plugin generators
This commit is contained in:
parent
e8c310edf6
commit
c694c8e25c
@ -1,3 +1,9 @@
|
||||
* Reading name and email from git for plugin gemspec.
|
||||
|
||||
Fixes #9589.
|
||||
|
||||
*Arun Agrawal*, *Abd ar-Rahman Hamidi*, *Roman Shmatov*
|
||||
|
||||
* Fix `console` and `generators` blocks defined at different environments.
|
||||
|
||||
Fixes #14748.
|
||||
|
@ -288,6 +288,10 @@ def mountable?
|
||||
options[:mountable]
|
||||
end
|
||||
|
||||
def skip_git?
|
||||
options[:skip_git]
|
||||
end
|
||||
|
||||
def with_dummy_app?
|
||||
options[:skip_test_unit].blank? || options[:dummy_path] != 'test/dummy'
|
||||
end
|
||||
@ -305,16 +309,20 @@ def camelized
|
||||
end
|
||||
|
||||
def author
|
||||
@author ||= begin
|
||||
git_user_name = `git config user.name`.chomp rescue ''
|
||||
git_user_name.blank? ? "TODO: Write your name" : git_user_name
|
||||
default = "TODO: Write your name"
|
||||
if skip_git?
|
||||
@author = default
|
||||
else
|
||||
@author = `git config user.name`.chomp rescue default
|
||||
end
|
||||
end
|
||||
|
||||
def email
|
||||
@email ||= begin
|
||||
git_user_email = `git config user.email`.chomp rescue ''
|
||||
git_user_email.blank? ? "TODO: Write your email address" : git_user_email
|
||||
default = "TODO: Write your email address"
|
||||
if skip_git?
|
||||
@email = default
|
||||
else
|
||||
@email = `git config user.email`.chomp rescue default
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -372,11 +372,8 @@ def test_generating_controller_inside_mountable_engine
|
||||
end
|
||||
|
||||
def test_git_name_and_email_in_gemspec_file
|
||||
name = `git config user.name`.chomp rescue ''
|
||||
name = "TODO: Write your name" if name.blank?
|
||||
|
||||
email = `git config user.email`.chomp rescue ''
|
||||
email = "TODO: Write your email address" if email.blank?
|
||||
name = `git config user.name`.chomp rescue "TODO: Write your name"
|
||||
email = `git config user.email`.chomp rescue "TODO: Write your email address"
|
||||
|
||||
run_generator [destination_root]
|
||||
assert_file "bukkits.gemspec" do |contents|
|
||||
@ -385,9 +382,8 @@ def test_git_name_and_email_in_gemspec_file
|
||||
end
|
||||
end
|
||||
|
||||
def test_git_name_in_licence_file
|
||||
name = `git config user.name`.chomp rescue ''
|
||||
name = "TODO: Write your name" if name.blank?
|
||||
def test_git_name_in_license_file
|
||||
name = `git config user.name`.chomp rescue "TODO: Write your name"
|
||||
|
||||
run_generator [destination_root]
|
||||
assert_file "MIT-LICENSE" do |contents|
|
||||
@ -395,6 +391,20 @@ def test_git_name_in_licence_file
|
||||
end
|
||||
end
|
||||
|
||||
def test_no_details_from_git_when_skip_git
|
||||
name = "TODO: Write your name"
|
||||
email = "TODO: Write your email address"
|
||||
|
||||
run_generator [destination_root, '--skip-git']
|
||||
assert_file "MIT-LICENSE" do |contents|
|
||||
assert_match(/#{Regexp.escape(name)}/, contents)
|
||||
end
|
||||
assert_file "bukkits.gemspec" do |contents|
|
||||
assert_match(/#{Regexp.escape(name)}/, contents)
|
||||
assert_match(/#{Regexp.escape(email)}/, contents)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def action(*args, &block)
|
||||
silence(:stdout){ generator.send(*args, &block) }
|
||||
|
Loading…
Reference in New Issue
Block a user