mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Ensure stage not set
warning is displayed correctly
This commit is contained in:
parent
ea8ec9abc7
commit
96b1857d0b
5 changed files with 19 additions and 20 deletions
|
@ -1,2 +1,3 @@
|
||||||
#!/usr/bin/env cap
|
#!/usr/bin/env cap
|
||||||
|
include Capistrano::DSL
|
||||||
require 'capistrano/install'
|
require 'capistrano/install'
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Capistrano
|
||||||
if tasks_without_stage_dependency.include?(@top_level_tasks.first)
|
if tasks_without_stage_dependency.include?(@top_level_tasks.first)
|
||||||
@top_level_tasks
|
@top_level_tasks
|
||||||
else
|
else
|
||||||
@top_level_tasks.unshift('deploy:ensure_stage')
|
@top_level_tasks.unshift(ensure_stage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,15 +37,6 @@ module Capistrano
|
||||||
File.expand_path(File.join(File.dirname(__FILE__),'..','Capfile'))
|
File.expand_path(File.join(File.dirname(__FILE__),'..','Capfile'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def tasks_without_stage_dependency
|
|
||||||
defined_stages = Dir['config/deploy/*.rb'].map { |f| File.basename(f, '.rb') }
|
|
||||||
defined_stages + default_tasks
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_tasks
|
|
||||||
%w{install}
|
|
||||||
end
|
|
||||||
|
|
||||||
def version
|
def version
|
||||||
['--version', '-V',
|
['--version', '-V',
|
||||||
"Display the program version.",
|
"Display the program version.",
|
||||||
|
|
|
@ -11,11 +11,3 @@ set :log_level, :debug
|
||||||
|
|
||||||
set :pty, true
|
set :pty, true
|
||||||
|
|
||||||
namespace :deploy do
|
|
||||||
task :ensure_stage do
|
|
||||||
unless stage_set?
|
|
||||||
puts t(:stage_not_set)
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -32,5 +32,22 @@ module Capistrano
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ensure_stage
|
||||||
|
Rake::Task.define_task(:ensure_stage) do
|
||||||
|
unless stage_set?
|
||||||
|
puts t(:stage_not_set)
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def tasks_without_stage_dependency
|
||||||
|
stages + default_tasks
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_tasks
|
||||||
|
%w{install}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,8 +44,6 @@ namespace :deploy do
|
||||||
task :finished do
|
task :finished do
|
||||||
end
|
end
|
||||||
|
|
||||||
before :starting, :ensure_stage
|
|
||||||
|
|
||||||
desc 'Rollback to previous release.'
|
desc 'Rollback to previous release.'
|
||||||
task :rollback do
|
task :rollback do
|
||||||
%w{ starting started
|
%w{ starting started
|
||||||
|
|
Loading…
Reference in a new issue