capistrano 3.4.0 → 3.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +129 -0
  3. data/.github/issue_template.md +19 -0
  4. data/.github/pull_request_template.md +22 -0
  5. data/.github/release-drafter.yml +17 -0
  6. data/.github/workflows/push.yml +12 -0
  7. data/.gitignore +8 -5
  8. data/.rubocop.yml +62 -0
  9. data/CHANGELOG.md +1 -307
  10. data/CONTRIBUTING.md +63 -93
  11. data/DEVELOPMENT.md +127 -0
  12. data/Dangerfile +1 -0
  13. data/Gemfile +40 -3
  14. data/LICENSE.txt +1 -1
  15. data/README.md +127 -44
  16. data/RELEASING.md +17 -0
  17. data/Rakefile +13 -2
  18. data/UPGRADING-3.7.md +86 -0
  19. data/bin/cap +1 -1
  20. data/capistrano.gemspec +21 -24
  21. data/features/deploy.feature +35 -1
  22. data/features/doctor.feature +11 -0
  23. data/features/installation.feature +8 -3
  24. data/features/stage_failure.feature +9 -0
  25. data/features/step_definitions/assertions.rb +51 -18
  26. data/features/step_definitions/cap_commands.rb +9 -0
  27. data/features/step_definitions/setup.rb +53 -9
  28. data/features/subdirectory.feature +9 -0
  29. data/features/support/env.rb +5 -5
  30. data/features/support/remote_command_helpers.rb +12 -6
  31. data/features/support/vagrant_helpers.rb +17 -11
  32. data/lib/Capfile +1 -1
  33. data/lib/capistrano/all.rb +10 -10
  34. data/lib/capistrano/application.rb +47 -34
  35. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  36. data/lib/capistrano/configuration/filter.rb +17 -47
  37. data/lib/capistrano/configuration/host_filter.rb +29 -0
  38. data/lib/capistrano/configuration/null_filter.rb +9 -0
  39. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  40. data/lib/capistrano/configuration/question.rb +31 -9
  41. data/lib/capistrano/configuration/role_filter.rb +29 -0
  42. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  43. data/lib/capistrano/configuration/server.rb +29 -23
  44. data/lib/capistrano/configuration/servers.rb +21 -14
  45. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  46. data/lib/capistrano/configuration/variables.rb +112 -0
  47. data/lib/capistrano/configuration.rb +91 -44
  48. data/lib/capistrano/defaults.rb +26 -4
  49. data/lib/capistrano/deploy.rb +1 -1
  50. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  51. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  52. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  53. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  54. data/lib/capistrano/doctor/variables_doctor.rb +74 -0
  55. data/lib/capistrano/doctor.rb +6 -0
  56. data/lib/capistrano/dotfile.rb +1 -2
  57. data/lib/capistrano/dsl/env.rb +9 -47
  58. data/lib/capistrano/dsl/paths.rb +11 -25
  59. data/lib/capistrano/dsl/stages.rb +14 -2
  60. data/lib/capistrano/dsl/task_enhancements.rb +7 -12
  61. data/lib/capistrano/dsl.rb +47 -16
  62. data/lib/capistrano/framework.rb +1 -1
  63. data/lib/capistrano/i18n.rb +32 -24
  64. data/lib/capistrano/immutable_task.rb +30 -0
  65. data/lib/capistrano/install.rb +1 -1
  66. data/lib/capistrano/plugin.rb +95 -0
  67. data/lib/capistrano/proc_helpers.rb +13 -0
  68. data/lib/capistrano/scm/git.rb +100 -0
  69. data/lib/capistrano/scm/hg.rb +55 -0
  70. data/lib/capistrano/scm/plugin.rb +13 -0
  71. data/lib/capistrano/scm/svn.rb +56 -0
  72. data/lib/capistrano/scm/tasks/git.rake +73 -0
  73. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  74. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  75. data/lib/capistrano/scm.rb +7 -20
  76. data/lib/capistrano/setup.rb +20 -6
  77. data/lib/capistrano/tasks/console.rake +4 -8
  78. data/lib/capistrano/tasks/deploy.rake +105 -73
  79. data/lib/capistrano/tasks/doctor.rake +24 -0
  80. data/lib/capistrano/tasks/framework.rake +13 -14
  81. data/lib/capistrano/tasks/install.rake +14 -15
  82. data/lib/capistrano/templates/Capfile +21 -10
  83. data/lib/capistrano/templates/deploy.rb.erb +17 -26
  84. data/lib/capistrano/templates/stage.rb.erb +9 -9
  85. data/lib/capistrano/upload_task.rb +1 -1
  86. data/lib/capistrano/version.rb +1 -1
  87. data/lib/capistrano/version_validator.rb +5 -10
  88. data/spec/integration/dsl_spec.rb +289 -240
  89. data/spec/integration_spec_helper.rb +3 -5
  90. data/spec/lib/capistrano/application_spec.rb +23 -39
  91. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  92. data/spec/lib/capistrano/configuration/filter_spec.rb +83 -85
  93. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  94. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  95. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  96. data/spec/lib/capistrano/configuration/question_spec.rb +58 -26
  97. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  98. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +55 -0
  99. data/spec/lib/capistrano/configuration/server_spec.rb +106 -113
  100. data/spec/lib/capistrano/configuration/servers_spec.rb +129 -145
  101. data/spec/lib/capistrano/configuration_spec.rb +224 -63
  102. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  103. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  104. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  105. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  106. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  107. data/spec/lib/capistrano/dsl/paths_spec.rb +97 -59
  108. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +57 -37
  109. data/spec/lib/capistrano/dsl_spec.rb +84 -11
  110. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  111. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  112. data/spec/lib/capistrano/scm/git_spec.rb +184 -0
  113. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  114. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  115. data/spec/lib/capistrano/scm_spec.rb +7 -8
  116. data/spec/lib/capistrano/upload_task_spec.rb +7 -7
  117. data/spec/lib/capistrano/version_validator_spec.rb +61 -46
  118. data/spec/lib/capistrano_spec.rb +2 -3
  119. data/spec/spec_helper.rb +21 -8
  120. data/spec/support/Vagrantfile +9 -10
  121. data/spec/support/tasks/database.rake +3 -3
  122. data/spec/support/tasks/fail.rake +4 -3
  123. data/spec/support/tasks/failed.rake +2 -2
  124. data/spec/support/tasks/plugin.rake +6 -0
  125. data/spec/support/tasks/root.rake +4 -4
  126. data/spec/support/test_app.rb +64 -39
  127. metadata +100 -55
  128. data/.travis.yml +0 -13
  129. data/features/remote_file_task.feature +0 -14
  130. data/lib/capistrano/git.rb +0 -46
  131. data/lib/capistrano/hg.rb +0 -43
  132. data/lib/capistrano/svn.rb +0 -38
  133. data/lib/capistrano/tasks/git.rake +0 -81
  134. data/lib/capistrano/tasks/hg.rake +0 -52
  135. data/lib/capistrano/tasks/svn.rake +0 -52
  136. data/spec/lib/capistrano/git_spec.rb +0 -81
  137. data/spec/lib/capistrano/hg_spec.rb +0 -81
  138. data/spec/lib/capistrano/svn_spec.rb +0 -79
@@ -1,19 +1,18 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
-
5
4
  describe VersionValidator do
6
5
  let(:validator) { VersionValidator.new(version) }
7
6
  let(:version) { stub }
8
7
 
9
- describe '#new' do
10
- it 'takes a version' do
8
+ describe "#new" do
9
+ it "takes a version" do
11
10
  expect(validator)
12
11
  end
13
12
  end
14
13
 
15
- describe '#verify' do
16
- let(:current_version) { '3.0.1' }
14
+ describe "#verify" do
15
+ let(:current_version) { "3.0.1" }
17
16
 
18
17
  subject { validator.verify }
19
18
 
@@ -21,83 +20,99 @@ module Capistrano
21
20
  validator.stubs(:current_version).returns(current_version)
22
21
  end
23
22
 
24
- context 'with exact version' do
25
- context 'valid' do
26
- let(:version) { '3.0.1' }
23
+ context "with exact version" do
24
+ context "valid" do
25
+ let(:version) { "3.0.1" }
27
26
  it { expect(subject).to be_truthy }
28
27
  end
29
28
 
30
- context 'invalid - lower' do
31
- let(:version) { '3.0.0' }
29
+ context "invalid - lower" do
30
+ let(:version) { "3.0.0" }
32
31
 
33
- it 'fails' do
34
- expect { subject }.to raise_error
32
+ it "fails" do
33
+ expect { subject }.to raise_error(RuntimeError)
35
34
  end
36
35
  end
37
36
 
38
- context 'invalid - higher' do
39
- let(:version) { '3.0.2' }
37
+ context "invalid - higher" do
38
+ let(:version) { "3.0.2" }
40
39
 
41
- it 'fails' do
42
- expect { subject }.to raise_error
40
+ it "fails" do
41
+ expect { subject }.to raise_error(RuntimeError)
43
42
  end
44
43
  end
45
-
46
44
  end
47
45
 
48
- context 'with optimistic versioning' do
49
- context 'valid' do
50
- let(:version) { '>= 3.0.0' }
46
+ context "with optimistic versioning" do
47
+ context "valid" do
48
+ let(:version) { ">= 3.0.0" }
51
49
  it { expect(subject).to be_truthy }
52
50
  end
53
51
 
54
- context 'invalid - lower' do
55
- let(:version) { '<= 2.0.0' }
52
+ context "invalid - lower" do
53
+ let(:version) { "<= 2.0.0" }
56
54
 
57
- it 'fails' do
58
- expect { subject }.to raise_error
55
+ it "fails" do
56
+ expect { subject }.to raise_error(RuntimeError)
59
57
  end
60
58
  end
61
59
  end
62
60
 
63
-
64
-
65
- context 'with pessimistic versioning' do
66
- context '2 decimal places' do
67
- context 'valid' do
68
- let(:version) { '~> 3.0.0' }
61
+ context "with pessimistic versioning" do
62
+ context "2 decimal places" do
63
+ context "valid" do
64
+ let(:version) { "~> 3.0.0" }
69
65
  it { expect(subject).to be_truthy }
70
66
  end
71
67
 
72
- context 'invalid' do
73
- let(:version) { '~> 3.1.0' }
68
+ context "invalid" do
69
+ let(:version) { "~> 3.1.0" }
74
70
 
75
- it 'fails' do
76
- expect { subject }.to raise_error
71
+ it "fails" do
72
+ expect { subject }.to raise_error(RuntimeError)
77
73
  end
78
74
  end
79
75
  end
80
76
 
81
- context '1 decimal place' do
82
- let(:current_version) { '3.5.0' }
77
+ context "1 decimal place" do
78
+ let(:current_version) { "3.5.0" }
83
79
 
84
- context 'valid' do
85
- let(:version) { '~> 3.1' }
80
+ context "valid" do
81
+ let(:version) { "~> 3.1" }
86
82
  it { expect(subject).to be_truthy }
87
83
  end
88
84
 
89
- context 'invalid' do
90
- let(:version) { '~> 3.6' }
91
- it 'fails' do
92
- expect { subject }.to raise_error
85
+ context "invalid" do
86
+ let(:version) { "~> 3.6" }
87
+ it "fails" do
88
+ expect { subject }.to raise_error(RuntimeError)
93
89
  end
94
90
  end
95
91
  end
96
92
 
97
- end
93
+ context "with multiple versions" do
94
+ let(:current_version) { "3.5.9" }
98
95
 
99
- end
96
+ context "valid" do
97
+ let(:version) { [">= 3.5.0", "< 3.5.10"] }
98
+ it { is_expected.to be_truthy }
99
+ end
100
100
 
101
- end
101
+ context "invalid" do
102
+ let(:version) { [">= 3.5.0", "< 3.5.8"] }
103
+ it "fails" do
104
+ expect { subject }.to raise_error(RuntimeError)
105
+ end
106
+ end
102
107
 
108
+ context "invalid" do
109
+ let(:version) { ["> 3.5.9", "< 3.5.13"] }
110
+ it "fails" do
111
+ expect { subject }.to raise_error(RuntimeError)
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
103
118
  end
@@ -1,8 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
-
5
4
  describe Application do
6
- let(:app) { Application.new }
5
+ let(:app) { Application.new }
7
6
  end
8
7
  end
data/spec/spec_helper.rb CHANGED
@@ -1,16 +1,29 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'capistrano/all'
4
- require 'rspec'
5
- require 'mocha/api'
6
- require 'time'
3
+ require "capistrano/all"
4
+ require "rspec"
5
+ require "mocha/api"
6
+ require "time"
7
7
 
8
8
  # Requires supporting files with custom matchers and macros, etc,
9
9
  # in ./support/ and its subdirectories.
10
- Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
10
+ Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each { |f| require f }
11
11
 
12
12
  RSpec.configure do |config|
13
- config.raise_errors_for_deprecations!
13
+ config.raise_errors_for_deprecations!
14
14
  config.mock_framework = :mocha
15
- config.order = 'random'
15
+ config.order = "random"
16
+
17
+ config.around(:example, capture_io: true) do |example|
18
+ begin
19
+ Rake.application.options.trace_output = StringIO.new
20
+ $stdout = StringIO.new
21
+ $stderr = StringIO.new
22
+ example.run
23
+ ensure
24
+ Rake.application.options.trace_output = STDERR
25
+ $stdout = STDOUT
26
+ $stderr = STDERR
27
+ end
28
+ end
16
29
  end
@@ -1,20 +1,19 @@
1
- require 'open-uri'
1
+ require "open-uri"
2
2
 
3
3
  Vagrant.configure("2") do |config|
4
-
5
4
  config.ssh.insert_key = false
6
5
 
7
6
  [:app].each_with_index do |role, i|
8
- config.vm.define(role, primary: true) do |config|
9
- config.vm.define role
10
- config.vm.box = 'hashicorp/precise64'
11
- config.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
12
- config.vm.provision :shell, inline: 'sudo apt-get -y install git-core'
7
+ config.vm.define(role, primary: true) do |primary|
8
+ primary.vm.define role
9
+ primary.vm.box = "hashicorp/bionic64"
10
+ primary.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
11
+ primary.vm.provision :shell, inline: "sudo apt-get -y install git-core"
13
12
 
14
- vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r",&:read)
13
+ vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r", &:read)
15
14
 
16
- config.vm.provision :shell,
17
- inline: <<-INLINE
15
+ primary.vm.provision :shell,
16
+ inline: <<-INLINE
18
17
  install -d -m 700 /root/.ssh
19
18
  echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
20
19
  chmod 0600 /root/.ssh/authorized_keys
@@ -1,11 +1,11 @@
1
1
  namespace :deploy do
2
2
  namespace :check do
3
- task :linked_files => 'config/database.yml'
3
+ task linked_files: "config/database.yml"
4
4
  end
5
5
  end
6
6
 
7
- remote_file 'config/database.yml' => '/tmp/database.yml', roles: :all
7
+ remote_file "config/database.yml" => "/tmp/database.yml", :roles => :all
8
8
 
9
- file '/tmp/database.yml' do |t|
9
+ file "/tmp/database.yml" do |t|
10
10
  sh "touch #{t.name}"
11
11
  end
@@ -1,7 +1,8 @@
1
- set :fail, proc { fail }
2
- before 'deploy:starting', :fail do
1
+ set :fail, proc { raise }
2
+ before "deploy:starting", :fail do
3
3
  on roles :all do
4
- execute :touch, shared_path.join('fail')
4
+ execute :mkdir, "-p", shared_path
5
+ execute :touch, shared_path.join("fail")
5
6
  end
6
7
  fetch(:fail)
7
8
  end
@@ -1,5 +1,5 @@
1
- after 'deploy:failed', :failed do
1
+ after "deploy:failed", :custom_failed do
2
2
  on roles :all do
3
- execute :touch, shared_path.join('failed')
3
+ execute :touch, shared_path.join("failed")
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ # This rake file is used by plugin_spec.rb.
2
+
3
+ task :plugin_test do
4
+ # Example of invoking a helper method provided by the plugin
5
+ hello
6
+ end
@@ -1,11 +1,11 @@
1
1
  task :am_i_root do
2
2
  on roles(:all) do |host|
3
- host.user = 'root'
4
- ident = capture :id, '-a'
3
+ host.user = "root"
4
+ ident = capture :id, "-a"
5
5
  info "I am #{ident}"
6
6
  end
7
- on roles(:all) do |host|
8
- ident = capture :id, '-a'
7
+ on roles(:all) do |_host|
8
+ ident = capture :id, "-a"
9
9
  info "I am #{ident}"
10
10
  end
11
11
  end
@@ -1,5 +1,6 @@
1
- require 'fileutils'
2
- require 'pathname'
1
+ require "English"
2
+ require "fileutils"
3
+ require "pathname"
3
4
 
4
5
  module TestApp
5
6
  extend self
@@ -9,15 +10,17 @@ module TestApp
9
10
  end
10
11
 
11
12
  def default_config
12
- %{
13
+ <<-CONFIG
13
14
  set :deploy_to, '#{deploy_to}'
14
- set :repo_url, 'git://github.com/capistrano/capistrano.git'
15
+ set :repo_url, 'https://github.com/capistrano/capistrano.git'
15
16
  set :branch, 'master'
16
17
  set :ssh_options, { keys: "\#{ENV['HOME']}/.vagrant.d/insecure_private_key", auth_methods: ['publickey'] }
17
18
  server 'vagrant@localhost:2220', roles: %w{web app}
18
19
  set :linked_files, #{linked_files}
19
20
  set :linked_dirs, #{linked_dirs}
20
- }
21
+ set :format_options, log_file: nil
22
+ set :local_user, #{current_user.inspect}
23
+ CONFIG
21
24
  end
22
25
 
23
26
  def linked_files
@@ -29,45 +32,52 @@ module TestApp
29
32
  end
30
33
 
31
34
  def linked_dirs
32
- %w{bin log public/system vendor/bundle}
35
+ %w{bin log public/system}
33
36
  end
34
37
 
35
38
  def create_test_app
36
39
  FileUtils.rm_rf(test_app_path)
37
40
  FileUtils.mkdir(test_app_path)
38
41
 
39
- File.open(gemfile, 'w+') do |file|
42
+ File.open(gemfile, "w+") do |file|
43
+ file.write "source 'https://rubygems.org'\n"
40
44
  file.write "gem 'capistrano', path: '#{path_to_cap}'"
41
45
  end
42
46
 
43
47
  Dir.chdir(test_app_path) do
44
- %x[bundle]
48
+ run "bundle"
45
49
  end
46
50
  end
47
51
 
48
52
  def install_test_app_with(config)
49
53
  create_test_app
50
54
  Dir.chdir(test_app_path) do
51
- %x[bundle exec cap install STAGES=#{stage}]
55
+ run "cap install STAGES=#{stage}"
52
56
  end
53
57
  write_local_deploy_file(config)
54
58
  end
55
59
 
56
60
  def write_local_deploy_file(config)
57
- File.open(test_stage_path, 'w') do |file|
61
+ File.open(test_stage_path, "w") do |file|
58
62
  file.write config
59
63
  end
60
64
  end
61
65
 
66
+ def write_local_stage_file(filename, config=nil)
67
+ File.open(test_app_path.join("config/deploy/#{filename}"), "w") do |file|
68
+ file.write(config) if config
69
+ end
70
+ end
71
+
62
72
  def append_to_deploy_file(config)
63
- File.open(test_stage_path, 'a') do |file|
73
+ File.open(test_stage_path, "a") do |file|
64
74
  file.write config + "\n"
65
75
  end
66
76
  end
67
77
 
68
78
  def prepend_to_capfile(config)
69
79
  current_capfile = File.read(capfile)
70
- File.open(capfile, 'w') do |file|
80
+ File.open(capfile, "w") do |file|
71
81
  file.write config
72
82
  file.write current_capfile
73
83
  end
@@ -78,79 +88,81 @@ module TestApp
78
88
  end
79
89
 
80
90
  def create_shared_file(path)
81
- File.open(shared_path.join(path), 'w')
91
+ File.open(shared_path.join(path), "w")
82
92
  end
83
93
 
84
- def cap(task)
85
- run "bundle exec cap #{stage} #{task}"
94
+ def cap(task, subdirectory=nil)
95
+ run "cap #{stage} #{task} --trace", subdirectory
86
96
  end
87
97
 
88
- def run(command)
98
+ def run(command, subdirectory=nil)
89
99
  output = nil
90
- Dir.chdir(test_app_path) do
91
- output = %x[#{command}]
100
+ command = "bundle exec #{command}" unless command =~ /^bundle\b/
101
+ dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path
102
+ Dir.chdir(dir) do
103
+ output = with_clean_bundler_env { `#{command}` }
92
104
  end
93
- [$?.success?, output]
105
+ [$CHILD_STATUS.success?, output]
94
106
  end
95
107
 
96
108
  def stage
97
- 'test'
109
+ "test"
98
110
  end
99
111
 
100
112
  def test_stage_path
101
- test_app_path.join('config/deploy/test.rb')
113
+ test_app_path.join("config/deploy/test.rb")
102
114
  end
103
115
 
104
116
  def test_app_path
105
- Pathname.new('/tmp/test_app')
117
+ Pathname.new("/tmp/test_app")
106
118
  end
107
119
 
108
120
  def deploy_to
109
- Pathname.new('/home/vagrant/var/www/deploy')
121
+ Pathname.new("/home/vagrant/var/www/deploy")
110
122
  end
111
123
 
112
124
  def shared_path
113
- deploy_to.join('shared')
125
+ deploy_to.join("shared")
114
126
  end
115
127
 
116
128
  def current_path
117
- deploy_to.join('current')
129
+ deploy_to.join("current")
118
130
  end
119
131
 
120
132
  def releases_path
121
- deploy_to.join('releases')
133
+ deploy_to.join("releases")
122
134
  end
123
135
 
124
- def release_path
125
- releases_path.join(timestamp)
136
+ def release_path(t=timestamp)
137
+ releases_path.join(t)
126
138
  end
127
139
 
128
- def timestamp
129
- Time.now.utc.strftime("%Y%m%d%H%M%S")
140
+ def timestamp(offset=0)
141
+ (Time.now.utc + offset).strftime("%Y%m%d%H%M%S")
130
142
  end
131
143
 
132
144
  def repo_path
133
- deploy_to.join('repo')
145
+ deploy_to.join("repo")
134
146
  end
135
147
 
136
148
  def path_to_cap
137
- File.expand_path('.')
149
+ File.expand_path(".")
138
150
  end
139
151
 
140
152
  def gemfile
141
- test_app_path.join('Gemfile')
153
+ test_app_path.join("Gemfile")
142
154
  end
143
155
 
144
156
  def capfile
145
- test_app_path.join('Capfile')
157
+ test_app_path.join("Capfile")
146
158
  end
147
159
 
148
160
  def current_user
149
- `whoami`.chomp
161
+ "(GitHub Web Flow) via ShipIt"
150
162
  end
151
163
 
152
164
  def task_dir
153
- test_app_path.join('lib/capistrano/tasks')
165
+ test_app_path.join("lib/capistrano/tasks")
154
166
  end
155
167
 
156
168
  def copy_task_to_test_app(source)
@@ -158,15 +170,15 @@ module TestApp
158
170
  end
159
171
 
160
172
  def config_path
161
- test_app_path.join('config')
173
+ test_app_path.join("config")
162
174
  end
163
175
 
164
176
  def move_configuration_to_custom_location(location)
165
177
  prepend_to_capfile(
166
- %{
178
+ <<-CONFIG
167
179
  set :stage_config_path, "app/config/deploy"
168
180
  set :deploy_config_path, "app/config/deploy.rb"
169
- }
181
+ CONFIG
170
182
  )
171
183
 
172
184
  location = test_app_path.join(location)
@@ -174,4 +186,17 @@ module TestApp
174
186
  FileUtils.mv(config_path, location)
175
187
  end
176
188
 
189
+ def git_wrapper_path_glob
190
+ "/tmp/git-ssh-*.sh"
191
+ end
192
+
193
+ def with_clean_bundler_env(&block)
194
+ return yield unless defined?(Bundler)
195
+
196
+ if Bundler.respond_to?(:with_unbundled_env)
197
+ Bundler.with_unbundled_env(&block)
198
+ else
199
+ Bundler.with_clean_env(&block)
200
+ end
201
+ end
177
202
  end