aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails_generator/commands.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb
index 9bc20b1c79..f72fb3d5c6 100644
--- a/railties/lib/rails_generator/commands.rb
+++ b/railties/lib/rails_generator/commands.rb
@@ -299,12 +299,26 @@ module Rails
logger.exists relative_path
else
logger.create relative_path
- FileUtils.mkdir_p(path) unless options[:pretend]
-
- # Optionally add file to subversion
- system("svn add #{path}") if options[:svn]
- end
- end
+ unless options[:pretend]
+ FileUtils.mkdir_p(path)
+
+ # Subversion doesn't do path adds, so we need to add
+ # each directory individually.
+ # So stack up the directory tree and add the paths to
+ # subversion in order without recursion.
+ if options[:svn]
+ stack=[relative_path]
+ until File.dirname(stack.last) == stack.last # dirname('.') == '.'
+ stack.push File.dirname(stack.last)
+ end
+ stack.reverse_each do |rel_path|
+ svn_path = destination_path(rel_path)
+ system("svn add -N #{svn_path}") unless File.directory?(File.join(svn_path, '.svn'))
+ end
+ end
+ end
+ end
+ end
# Display a README.
def readme(*relative_sources)