From 21d50e4d1a07566939e11f6911279e562565e176 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 23 Nov 2005 22:24:16 +0000 Subject: script/plugin: handle root paths and plugin names which contain spaces. References #2995. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3175 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/commands/plugin.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'railties/lib/commands') diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb index dd25c8e60f..9ae0a40314 100644 --- a/railties/lib/commands/plugin.rb +++ b/railties/lib/commands/plugin.rb @@ -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 @@ class RailsEnvironment 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,12 +123,12 @@ class RailsEnvironment 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") @@ -136,7 +136,7 @@ class RailsEnvironment 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 @@ class Plugin 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 @@ module Commands 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 -- cgit v1.2.3