Skip to content

Commit

Permalink
Ensure stage not set warning is displayed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
seenmyfate committed Sep 6, 2013
1 parent ea8ec9a commit 96b1857
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions lib/Capfile
@@ -1,2 +1,3 @@
#!/usr/bin/env cap #!/usr/bin/env cap
include Capistrano::DSL
require 'capistrano/install' require 'capistrano/install'
11 changes: 1 addition & 10 deletions lib/capistrano/application.rb
Expand Up @@ -26,7 +26,7 @@ def top_level_tasks
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


Expand All @@ -37,15 +37,6 @@ def capfile
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.",
Expand Down
8 changes: 0 additions & 8 deletions lib/capistrano/defaults.rb
Expand Up @@ -11,11 +11,3 @@


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
17 changes: 17 additions & 0 deletions lib/capistrano/dsl/task_enhancements.rb
Expand Up @@ -32,5 +32,22 @@ def define_remote_file_task(task, target_roles)
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
2 changes: 0 additions & 2 deletions lib/capistrano/tasks/framework.rake
Expand Up @@ -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
Expand Down

0 comments on commit 96b1857

Please sign in to comment.