Permalink
Browse files

Added .gitkeep to empty directories and --skip-git to skip gitignore/…

…gitkeep files
  • Loading branch information...
1 parent 5eb3cec commit 5d8342cc325bc9f46bfe61bf3534248b6ad3216f @dhh dhh committed Dec 31, 2009
Showing with 13 additions and 6 deletions.
  1. +13 −6 railties/lib/rails/generators/rails/app/app_generator.rb
@@ -34,6 +34,9 @@ class AppGenerator < Base
class_option :skip_prototype, :type => :boolean, :aliases => "-J", :default => false,
:desc => "Skip Prototype files"
+ class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
+ :desc => "Skip Git ignores and keeps"
+
# Add bin/rails options
class_option :version, :type => :boolean, :aliases => "-v", :group => :rails,
:desc => "Show Rails version number and quit"
@@ -58,7 +61,7 @@ def create_root
def create_root_files
copy_file "README"
- copy_file "gitignore", ".gitignore"
+ copy_file "gitignore", ".gitignore" unless options[:skip_git]
template "Rakefile"
template "config.ru"
template "Gemfile"
@@ -101,7 +104,7 @@ def create_doc_files
def create_lib_files
empty_directory "lib"
- empty_directory "lib/tasks"
+ empty_directory_with_gitkeep "lib/tasks"
end
def create_log_files
@@ -124,7 +127,7 @@ def create_public_image_files
end
def create_public_stylesheets_files
- directory "public/stylesheets"
+ empty_directory_with_gitkeep "public/stylesheets"
end
def create_prototype_files
@@ -149,13 +152,13 @@ def create_tmp_files
inside "tmp" do
%w(sessions sockets cache pids).each do |dir|
- empty_directory dir
+ empty_directory_with_gitkeep(dir)
end
end
end
def create_vendor_files
- empty_directory "vendor/plugins"
+ empty_directory_with_gitkeep "vendor/plugins"
end
def apply_rails_template
@@ -165,7 +168,6 @@ def apply_rails_template
end
protected
-
attr_accessor :rails_template
def set_default_accessors!
@@ -219,5 +221,10 @@ def mysql_socket
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
end
+
+ def empty_directory_with_gitkeep(destination, config = {})
+ empty_directory(destination, config)
+ create_file("#{destination}/.gitkeep") unless options[:skip_git]
+ end
end
end

0 comments on commit 5d8342c

Please sign in to comment.