mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Batch rm -rf calls in deploy:cleanup. (#2027)
This commit is contained in:
parent
55679083fa
commit
96fdb4c8c5
4 changed files with 16 additions and 5 deletions
|
@ -19,6 +19,7 @@ gem "capistrano", github: "capistrano/capistrano", require: false
|
|||
[master]: https://github.com/capistrano/capistrano/compare/v3.11.0...HEAD
|
||||
|
||||
* Your contribution here!
|
||||
* [#2027](https://github.com/capistrano/capistrano/pull/2027): Batch rm -rf calls in deploy:cleanup. [@azin634](https://github.com/azin634)
|
||||
|
||||
## [`3.11.0`] (2018-06-02)
|
||||
|
||||
|
|
|
@ -70,6 +70,12 @@ Feature: Deploy
|
|||
Then 3 valid releases are kept
|
||||
And the current directory will be a symlink to the release
|
||||
|
||||
Scenario: Cleanup when there are more releases than arguments can handle
|
||||
Given config stage file has line "set :keep_releases, 3"
|
||||
And 5000 valid existing releases
|
||||
When I run cap "deploy:cleanup"
|
||||
Then 3 valid releases are kept
|
||||
|
||||
Scenario: Rolling Back
|
||||
Given I make 2 deployments
|
||||
When I run cap "deploy:rollback"
|
||||
|
|
|
@ -80,10 +80,12 @@ end
|
|||
|
||||
Given(/^(\d+) valid existing releases$/) do |num|
|
||||
a_day = 86_400 # in seconds
|
||||
offset = -(a_day * num.to_i)
|
||||
num.to_i.times do
|
||||
run_vagrant_command("mkdir -p #{TestApp.release_path(TestApp.timestamp(offset))}")
|
||||
offset += a_day
|
||||
(1...num).each_slice(100) do |num_batch|
|
||||
dirs = num_batch.map do |i|
|
||||
offset = -(a_day * i)
|
||||
TestApp.release_path(TestApp.timestamp(offset))
|
||||
end
|
||||
run_vagrant_command("mkdir -p #{dirs.join(' ')}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -168,7 +168,9 @@ namespace :deploy do
|
|||
debug t(:no_current_release, host: host.to_s)
|
||||
end
|
||||
if directories.any?
|
||||
execute :rm, "-rf", *directories
|
||||
directories.each_slice(100) do |directories_batch|
|
||||
execute :rm, "-rf", *directories_batch
|
||||
end
|
||||
else
|
||||
info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue