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

Users can now pass :branch for git plugins and :revision for subversion plugins

[#2352 status:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Matt Duncan 2009-08-08 18:07:17 -04:00 committed by Pratik Naik
parent 3ea091e1cc
commit bee3e099bd
2 changed files with 25 additions and 1 deletions

View file

@ -5,22 +5,31 @@ module Rails
module Actions module Actions
# Install a plugin. You must provide either a Subversion url or Git url. # Install a plugin. You must provide either a Subversion url or Git url.
# For a Git-hosted plugin, you can specify if it should be added as a submodule instead of cloned. #
# For a Git-hosted plugin, you can specify a branch and
# whether it should be added as a submodule instead of cloned.
#
# For a Subversion-hosted plugin you can specify a revision.
# #
# ==== Examples # ==== Examples
# #
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git' # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :branch => 'stable'
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk' # plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk', :revision => 1234
# #
def plugin(name, options) def plugin(name, options)
log :plugin, name log :plugin, name
if options[:git] && options[:submodule] if options[:git] && options[:submodule]
options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
in_root do in_root do
run "git submodule add #{options[:git]} vendor/plugins/#{name}", :verbose => false run "git submodule add #{options[:git]} vendor/plugins/#{name}", :verbose => false
end end
elsif options[:git] || options[:svn] elsif options[:git] || options[:svn]
options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
options[:svn] = "-r #{options[:revision]} #{options[:svn]}" if options[:revision]
in_root do in_root do
run_ruby_script "script/plugin install #{options[:svn] || options[:git]}", :verbose => false run_ruby_script "script/plugin install #{options[:svn] || options[:git]}", :verbose => false
end end

View file

@ -29,11 +29,26 @@ class ActionsTest < GeneratorsTestCase
action :plugin, 'restful-authentication', :svn => @svn_plugin_uri action :plugin, 'restful-authentication', :svn => @svn_plugin_uri
end end
def test_plugin_with_git_option_and_branch_should_run_plugin_install
generator.expects(:run_ruby_script).once.with("script/plugin install -b stable #{@git_plugin_uri}", :verbose => false)
action :plugin, 'restful-authentication', :git => @git_plugin_uri, :branch => 'stable'
end
def test_plugin_with_svn_option_and_revision_should_run_plugin_install
generator.expects(:run_ruby_script).once.with("script/plugin install -r 1234 #{@svn_plugin_uri}", :verbose => false)
action :plugin, 'restful-authentication', :svn => @svn_plugin_uri, :revision => 1234
end
def test_plugin_with_git_option_and_submodule_should_use_git_scm def test_plugin_with_git_option_and_submodule_should_use_git_scm
generator.expects(:run).with("git submodule add #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false) generator.expects(:run).with("git submodule add #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false)
action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true
end end
def test_plugin_with_git_option_and_submodule_should_use_git_scm
generator.expects(:run).with("git submodule add -b stable #{@git_plugin_uri} vendor/plugins/rest_auth", :verbose => false)
action :plugin, 'rest_auth', :git => @git_plugin_uri, :submodule => true, :branch => 'stable'
end
def test_plugin_with_no_options_should_skip_method def test_plugin_with_no_options_should_skip_method
generator.expects(:run).never generator.expects(:run).never
action :plugin, 'rest_auth', {} action :plugin, 'rest_auth', {}