Permalink
Browse files

script/plugin: handle root paths and plugin names which contain space…

…s. References #2995.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3175 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d933627 commit 21d50e4d1a07566939e11f6911279e562565e176 @jeremy jeremy committed Nov 23, 2005
Showing with 13 additions and 10 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +11 −10 railties/lib/commands/plugin.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* script/plugin: handle root paths and plugin names which contain spaces. #2995 [justin@aspect.net]
+
* Model generator: correct relative path to test_helper in unit test. [Jeremy Kemper]
* Make the db_schema_dump task honor the SCHEMA environment variable if present the way db_schema_import does. #2931. [Blair Zajac]
@@ -61,7 +61,7 @@ class RailsEnvironment
def initialize(dir)
@root = dir
end
-
+
def self.find(dir=nil)
dir ||= pwd
while dir.length > 1
@@ -104,14 +104,14 @@ def use_svn?
def use_externals?
use_svn? && File.directory?("#{root}/vendor/plugins/.svn")
end
-
+
def use_checkout?
# this is a bit of a guess. we assume that if the rails environment
# is under subversion than they probably want the plugin checked out
# instead of exported. This can be overridden on the command line
File.directory?("#{root}/.svn")
end
-
+
def best_install_method
return :http unless use_svn?
case
@@ -123,20 +123,20 @@ def best_install_method
def externals
return [] unless use_externals?
- ext = `svn propget svn:externals #{root}/vendor/plugins`
+ ext = `svn propget svn:externals "#{root}/vendor/plugins"`
ext.reject{ |line| line.strip == '' }.map do |line|
line.strip.split(/\s+/, 2)
end
end
-
+
def externals=(items)
unless items.is_a? String
items = items.map{|name,uri| "#{name.ljust(29)} #{uri.chomp('/')}"}.join("\n")
end
Tempfile.open("svn-set-prop") do |file|
file.write(items)
file.flush
- system("svn propset -q svn:externals -F #{file.path} #{root}/vendor/plugins")
+ system("svn propset -q svn:externals -F #{file.path} \"#{root}/vendor/plugins\"")
end
end
@@ -212,7 +212,7 @@ def install_using_http(options = {})
def svn_command(cmd, options = {})
root = rails_env.root
mkdir_p "#{root}/vendor/plugins"
- base_cmd = "svn #{cmd} #{uri} #{root}/vendor/plugins/#{name}"
+ base_cmd = "svn #{cmd} #{uri} \"#{root}/vendor/plugins/#{name}\""
base_cmd += ' -q' if options[:quiet] and not $verbose
base_cmd += " -r #{options[:revision]}" if options[:revision]
system(base_cmd)
@@ -754,14 +754,15 @@ def options
def parse!(args)
options.parse!(args)
root = @base_command.environment.root
- args = Dir["#{root}/vendor/plugins/*"].map do |f|
+ cd root
+ args = Dir["vendor/plugins/*"].map do |f|
File.directory?("#{f}/.svn") ? File.basename(f) : nil
end.compact if args.empty?
- cd "#{root}/vendor/plugins"
+ cd "vendor/plugins"
args.each do |name|
if File.directory?(name)
puts "Updating plugin: #{name}"
- system("svn #{$verbose ? '' : '-q'} up #{name} #{@revision ? "-r #{@revision}" : ''}")
+ system("svn #{$verbose ? '' : '-q'} up \"#{name}\" #{@revision ? "-r #{@revision}" : ''}")
else
puts "Plugin doesn't exist: #{name}"
end

0 comments on commit 21d50e4

Please sign in to comment.