lib/capistrano/bundle_rsync/git.rb in capistrano-bundle_rsync-0.4.6 vs lib/capistrano/bundle_rsync/git.rb in capistrano-bundle_rsync-0.4.7

- old
+ new

@@ -33,9 +33,25 @@ execute :git, :archive, fetch(:branch), '| tar -x -C', "#{config.local_release_path}" end end end + def clean_release + # Do not remove if :bundle_rsync_local_release_path is directly specified + # because releases/#{datetime} directories are no longer created. + return if fetch(:bundle_rsync_local_release_path) + releases = capture(:ls, '-x', config.local_releases_path).split + if releases.count >= config.keep_releases + directories = (releases - releases.last(config.keep_releases)) + if directories.any? + directories_str = directories.map do |release| + File.join(config.local_releases_path, release) + end.join(" ") + execute :rm, '-rf', directories_str + end + end + end + def rsync_release hosts = ::Capistrano::Configuration.env.filter(release_roles(:all)) rsync_options = config.rsync_options Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host| ssh = config.build_ssh_command(host)