capistrano/capistrano — pull request #1141 by plu (2014-09-28 17:02:13+00:00)
Title: Sort releases by timestamp for rollback/cleanup

When you just use Capistrano for deployment, sorting the releases by name is just working fine. I have a different scenario though, where it does not work: I use Chef and the application/application_ruby cookbook to do the first deployment. This one creates a sha based directory name, by default. So the sorting by name will be messed up for Capistrano.

Example:

```console
drwxrwxr-x 14 deploy deploy 4096 Sep 28 18:49 20140928164907
drwxrwxr-x 14 deploy deploy 4096 Sep 28 18:49 20140928164944
drwxrwxr-x 14 deploy deploy 4096 Sep 28 18:50 20140928164958
drwxrwxr-x 14 deploy deploy 4096 Sep 28 18:50 20140928165015
drwxr-xr-x 16 deploy deploy 4096 Sep 28 18:48 765a5c8c3879a124c30a4c1de46737acfd863a05
```

Here the oldest deployement is the one (765a5c8c3879a124c30a4c1de46737acfd863a05), made by Chef at 18:48 o'clock. But Capistrano will clean up 20140928164907.

I know that Chef has a different deployment strategy called Chef::Provider::Deploy::Timestamped. I have tried to use that one, but it does not play well with the application/application_ruby cookbook. And getting a change into the opscode repositories takes ages :(. So I decided to fix this on the Capistrano side :). This will also fix other scenarios where something else than Chef was deploying into the releases folder without naming it in the same scheme as Capistrano.

If you decide this is a good change, please have a close look if I got the logic right! I don't want to mess up other people's deployments :). It's a bit confusing because `-t` is already reversing the order.

Thanks,
plu