1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Merge pull request #1867 from capistrano/allow-cap-t-without-capfile

Allow `cap -T` to run without Capfile present
This commit is contained in:
Matt Brictson 2017-03-19 20:42:32 -07:00 committed by GitHub
commit 77481802b9
5 changed files with 24 additions and 8 deletions

View file

@ -13,6 +13,7 @@ gem "capistrano", :github => "capistrano/capistrano"
https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD
* Your contribution here! * Your contribution here!
* [#1867](https://github.com/capistrano/capistrano/pull/1867): Allow `cap -T` to run without Capfile present - [@mattbrictson](https://github.com/mattbrictson)
## `3.8.0` (2017-03-10) ## `3.8.0` (2017-03-10)

View file

@ -1,16 +1,21 @@
Feature: Installation Feature: Installation
Background: Background:
Given a test app with the default configuration Given a test app without any configuration
Scenario: The "install" task documentation can be viewed
When I run "cap -T"
Then the task is successful
And contains "cap install" in the output
Scenario: With default stages Scenario: With default stages
When I run cap "install" When I run "cap install"
Then the deploy.rb file is created Then the deploy.rb file is created
And the default stage files are created And the default stage files are created
And the tasks folder is created And the tasks folder is created
Scenario: With specified stages Scenario: With specified stages
When I run cap "install STAGES=qa,production" When I run "cap install STAGES=qa,production"
Then the deploy.rb file is created Then the deploy.rb file is created
And the specified stage files are created And the specified stage files are created
And the tasks folder is created And the tasks folder is created

View file

@ -2,6 +2,10 @@ Given(/^a test app with the default configuration$/) do
TestApp.install TestApp.install
end end
Given(/^a test app without any configuration$/) do
TestApp.create_test_app
end
Given(/^servers with the roles app and web$/) do Given(/^servers with the roles app and web$/) do
begin begin
vagrant_cli_command("up") vagrant_cli_command("up")

View file

@ -96,7 +96,7 @@ module Capistrano
end end
def load_imports def load_imports
if options.show_tasks if options.show_tasks && Rake::Task.task_defined?("load:defaults")
invoke "load:defaults" invoke "load:defaults"
set(:stage, "") set(:stage, "")
Dir[deploy_config_path].each { |f| add_import f } Dir[deploy_config_path].each { |f| add_import f }

View file

@ -44,14 +44,14 @@ module TestApp
end end
Dir.chdir(test_app_path) do Dir.chdir(test_app_path) do
`bundle` run "bundle"
end end
end end
def install_test_app_with(config) def install_test_app_with(config)
create_test_app create_test_app
Dir.chdir(test_app_path) do Dir.chdir(test_app_path) do
`bundle exec cap install STAGES=#{stage}` run "cap install STAGES=#{stage}"
end end
write_local_deploy_file(config) write_local_deploy_file(config)
end end
@ -91,14 +91,15 @@ module TestApp
end end
def cap(task, subdirectory=nil) def cap(task, subdirectory=nil)
run "bundle exec cap #{stage} #{task}", subdirectory run "cap #{stage} #{task} --trace", subdirectory
end end
def run(command, subdirectory=nil) def run(command, subdirectory=nil)
output = nil output = nil
command = "bundle exec #{command}" unless command =~ /^bundle\b/
dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path
Dir.chdir(dir) do Dir.chdir(dir) do
output = `#{command}` output = with_clean_bundler_env { `#{command}` }
end end
[$CHILD_STATUS.success?, output] [$CHILD_STATUS.success?, output]
end end
@ -187,4 +188,9 @@ module TestApp
def git_wrapper_path def git_wrapper_path
"/tmp/git-ssh-my_app_name-#{stage}-#{current_user}.sh" "/tmp/git-ssh-my_app_name-#{stage}-#{current_user}.sh"
end end
def with_clean_bundler_env(&block)
return yield unless defined?(Bundler)
Bundler.with_clean_env(&block)
end
end end