diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-02 07:55:04 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-02 07:55:04 +0000 |
commit | 4bd64363c12a1b00faa52fcf4970fbfdc11c15ab (patch) | |
tree | b3b48e8e5f55dbca4bbb966b4ae25938bf1c7188 /railties | |
parent | 61bcbfbb9ca3fa4737dd20e1e6278c7b537c3337 (diff) | |
download | rails-4bd64363c12a1b00faa52fcf4970fbfdc11c15ab.tar.gz rails-4bd64363c12a1b00faa52fcf4970fbfdc11c15ab.tar.bz2 rails-4bd64363c12a1b00faa52fcf4970fbfdc11c15ab.zip |
Generated directories are recursively svn added, like mkdir -p. Closes #6416.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5395 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index fbf520fd42..8cb4c01cfd 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Generated directories are recursively svn added, like mkdir -p. #6416 [NeilW] + * resource and scaffold_resource generators add a restful route to config/routes.rb [Jeremy Kemper] * Revert environment changes for autoload_paths. [Koz] 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) |