The task depends on assets:clean and
assets:precompile, so each time it runs
public/assets is cleaned out and the assets are recompiled.
The task then calculates the etag (MD5 checksum) of each file, compares
it to the etag of the file on S3, and, if it’s different, copies the
asset up. If the etags are the same, it skips the file. Finally, after
uploading everything, the task runs through the contents of the asset
bucket, and removes any files that didn’t also exist in
public/assets on the local machine. This assumes the bucket
in question is only being used to serve assets for the current
application. Do not use this task as is if you are using the bucket to
serve additional content!

As a sanity check, the task aborts before making any changes if
public/assets is empty.

This task also takes advantage of Rake’s command line arguments feature
to let you run the task in “no-op” mode. In this mode, assets are still
removed locally and precompiled, but changes to S3 are reported but not
actually carried out. To run it in no-op mode, append
[noop] (really, anything in brackets) to the task name on
invocation: