mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1811 from markri/master
Fixes Bug #1810 removal of old releases
This commit is contained in:
commit
199b7854ac
3 changed files with 7 additions and 2 deletions
|
@ -8,6 +8,8 @@ https://github.com/capistrano/capistrano/compare/v3.7.0.beta1...HEAD
|
|||
|
||||
* Your contribution here!
|
||||
|
||||
* Fix the removal of old releases `deploy:cleanup`. Logic is changed because of unreliable modification times on folders. Removal of directories is now decided by sorting on folder names (name is generated from current datetime format YmdHis). Cleanup is skipped, and a warning is given when a folder name is in a different format.
|
||||
|
||||
## `3.7.0.beta1` (2016-11-02)
|
||||
|
||||
https://github.com/capistrano/capistrano/compare/v3.6.1...v3.7.0.beta1
|
||||
|
|
|
@ -12,6 +12,7 @@ en = {
|
|||
written_file: "create %{file}",
|
||||
question: "Please enter %{key} (%{default_value}): ",
|
||||
keeping_releases: "Keeping %{keep_releases} of %{releases} deployed releases on %{host}",
|
||||
skip_cleanup: "Skipping cleanup of old releases on %{host}; unexpected foldername found (should be timestamp)",
|
||||
no_old_releases: "No old releases (keeping newest %{keep_releases}) on %{host}",
|
||||
linked_file_does_not_exist: "linked file %{file} does not exist on %{host}",
|
||||
cannot_rollback: "There are no older releases to rollback to",
|
||||
|
|
|
@ -148,8 +148,10 @@ namespace :deploy do
|
|||
desc "Clean up old releases"
|
||||
task :cleanup do
|
||||
on release_roles :all do |host|
|
||||
releases = capture(:ls, "-xtr", releases_path).split
|
||||
if releases.count >= fetch(:keep_releases)
|
||||
releases = capture(:ls, "-x", releases_path).split
|
||||
if !(releases.all? { |e| /^\d{14}$/ =~ e })
|
||||
warn t(:skip_cleanup, host: host.to_s)
|
||||
elsif releases.count >= fetch(:keep_releases)
|
||||
info t(:keeping_releases, host: host.to_s, keep_releases: fetch(:keep_releases), releases: releases.count)
|
||||
directories = (releases - releases.last(fetch(:keep_releases)))
|
||||
if directories.any?
|
||||
|
|
Loading…
Reference in a new issue