提交 d451044e 编写于 作者: M Marcel Molina

Make the generator skip a file if it already exists and is identical to the new file.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2493 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 31baeeef
*SVN*
* Make the generator skip a file if it already exists and is identical to the new file.
* Add experimental plugin support #2335
* Made Rakefile aware of new .js files in script.aculo.us [Thomas Fuchs]
......
......@@ -146,11 +146,13 @@ def class_collisions(*class_names)
# the user what to do.
def file(relative_source, relative_destination, file_options = {})
# Determine full paths for source and destination files.
source = source_path(relative_source)
destination = destination_path(relative_destination)
source = source_path(relative_source)
destination = destination_path(relative_destination)
destination_exists = File.exists?(destination)
return logger.identical(relative_destination) if destination_exists and identical?(source, destination)
# Check for and resolve file collisions.
if File.exists?(destination)
if destination_exists
# Make a choice whether to overwrite the file. :force and
# :skip already have their mind made up, but give :ask a shot.
......@@ -207,6 +209,11 @@ def file(relative_source, relative_destination, file_options = {})
system("svn add #{destination}") if options[:svn]
end
# Checks if the source and the destination file are identical.
def identical?(source, destination)
IO.read(source) == IO.read(destination)
end
# Generate a file for a Rails application using an ERuby template.
# Looks up and evalutes a template by name and writes the result.
#
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册