capistrano 2.0.0 → 2.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +7 -0
- data/CHANGELOG +715 -18
- data/Gemfile +12 -0
- data/README.md +94 -0
- data/Rakefile +11 -0
- data/bin/cap +0 -0
- data/bin/capify +37 -22
- data/capistrano.gemspec +40 -0
- data/lib/capistrano/callback.rb +5 -1
- data/lib/capistrano/cli/execute.rb +10 -7
- data/lib/capistrano/cli/help.rb +39 -16
- data/lib/capistrano/cli/help.txt +44 -16
- data/lib/capistrano/cli/options.rb +71 -11
- data/lib/capistrano/cli/ui.rb +13 -1
- data/lib/capistrano/cli.rb +5 -5
- data/lib/capistrano/command.rb +215 -58
- data/lib/capistrano/configuration/actions/file_transfer.rb +29 -14
- data/lib/capistrano/configuration/actions/inspect.rb +3 -3
- data/lib/capistrano/configuration/actions/invocation.rb +212 -22
- data/lib/capistrano/configuration/alias_task.rb +26 -0
- data/lib/capistrano/configuration/callbacks.rb +26 -27
- data/lib/capistrano/configuration/connections.rb +130 -52
- data/lib/capistrano/configuration/execution.rb +34 -18
- data/lib/capistrano/configuration/loading.rb +91 -6
- data/lib/capistrano/configuration/log_formatters.rb +75 -0
- data/lib/capistrano/configuration/namespaces.rb +45 -12
- data/lib/capistrano/configuration/roles.rb +28 -2
- data/lib/capistrano/configuration/servers.rb +51 -10
- data/lib/capistrano/configuration/variables.rb +3 -3
- data/lib/capistrano/configuration.rb +20 -4
- data/lib/capistrano/errors.rb +12 -8
- data/lib/capistrano/ext/multistage.rb +62 -0
- data/lib/capistrano/ext/string.rb +5 -0
- data/lib/capistrano/extensions.rb +1 -1
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +8 -0
- data/lib/capistrano/logger.rb +112 -5
- data/lib/capistrano/processable.rb +55 -0
- data/lib/capistrano/recipes/compat.rb +2 -2
- data/lib/capistrano/recipes/deploy/assets.rb +185 -0
- data/lib/capistrano/recipes/deploy/dependencies.rb +2 -2
- data/lib/capistrano/recipes/deploy/local_dependency.rb +10 -2
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +54 -2
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +169 -0
- data/lib/capistrano/recipes/deploy/scm/base.rb +31 -11
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +14 -14
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +10 -8
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +12 -1
- data/lib/capistrano/recipes/deploy/scm/git.rb +293 -0
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +23 -15
- data/lib/capistrano/recipes/deploy/scm/none.rb +55 -0
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +54 -28
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +35 -17
- data/lib/capistrano/recipes/deploy/scm.rb +1 -1
- data/lib/capistrano/recipes/deploy/strategy/base.rb +32 -4
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +238 -43
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +1 -1
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +11 -1
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +21 -0
- data/lib/capistrano/recipes/deploy/strategy.rb +1 -1
- data/lib/capistrano/recipes/deploy.rb +265 -123
- data/lib/capistrano/recipes/standard.rb +1 -1
- data/lib/capistrano/role.rb +102 -0
- data/lib/capistrano/server_definition.rb +6 -1
- data/lib/capistrano/shell.rb +30 -33
- data/lib/capistrano/ssh.rb +46 -60
- data/lib/capistrano/task_definition.rb +16 -8
- data/lib/capistrano/transfer.rb +218 -0
- data/lib/capistrano/version.rb +6 -17
- data/lib/capistrano.rb +4 -1
- data/test/cli/execute_test.rb +3 -3
- data/test/cli/help_test.rb +33 -7
- data/test/cli/options_test.rb +109 -6
- data/test/cli/ui_test.rb +2 -2
- data/test/cli_test.rb +3 -3
- data/test/command_test.rb +144 -124
- data/test/configuration/actions/file_transfer_test.rb +41 -20
- data/test/configuration/actions/inspect_test.rb +21 -7
- data/test/configuration/actions/invocation_test.rb +91 -30
- data/test/configuration/alias_task_test.rb +118 -0
- data/test/configuration/callbacks_test.rb +41 -46
- data/test/configuration/connections_test.rb +187 -36
- data/test/configuration/execution_test.rb +18 -2
- data/test/configuration/loading_test.rb +17 -4
- data/test/configuration/namespace_dsl_test.rb +54 -5
- data/test/configuration/roles_test.rb +114 -4
- data/test/configuration/servers_test.rb +97 -4
- data/test/configuration/variables_test.rb +12 -2
- data/test/configuration_test.rb +9 -13
- data/test/deploy/local_dependency_test.rb +76 -0
- data/test/deploy/remote_dependency_test.rb +146 -0
- data/test/deploy/scm/accurev_test.rb +23 -0
- data/test/deploy/scm/base_test.rb +1 -1
- data/test/deploy/scm/bzr_test.rb +51 -0
- data/test/deploy/scm/darcs_test.rb +37 -0
- data/test/deploy/scm/git_test.rb +221 -0
- data/test/deploy/scm/mercurial_test.rb +134 -0
- data/test/deploy/scm/none_test.rb +35 -0
- data/test/deploy/scm/perforce_test.rb +23 -0
- data/test/deploy/scm/subversion_test.rb +40 -0
- data/test/deploy/strategy/copy_test.rb +240 -26
- data/test/extensions_test.rb +2 -2
- data/test/logger_formatting_test.rb +149 -0
- data/test/logger_test.rb +13 -2
- data/test/recipes_test.rb +25 -0
- data/test/role_test.rb +11 -0
- data/test/server_definition_test.rb +15 -2
- data/test/shell_test.rb +33 -1
- data/test/ssh_test.rb +40 -24
- data/test/task_definition_test.rb +18 -2
- data/test/transfer_test.rb +168 -0
- data/test/utils.rb +27 -33
- metadata +215 -102
- data/MIT-LICENSE +0 -20
- data/README +0 -43
- data/examples/sample.rb +0 -14
- data/lib/capistrano/gateway.rb +0 -131
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/upgrade.rb +0 -33
- data/lib/capistrano/upload.rb +0 -146
- data/test/gateway_test.rb +0 -167
- data/test/upload_test.rb +0 -131
- data/test/version_test.rb +0 -24
data/test/cli/execute_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "utils"
|
|
2
2
|
require 'capistrano/cli/execute'
|
|
3
3
|
|
|
4
4
|
class CLIExecuteTest < Test::Unit::TestCase
|
|
@@ -15,7 +15,7 @@ class CLIExecuteTest < Test::Unit::TestCase
|
|
|
15
15
|
def setup
|
|
16
16
|
@cli = MockCLI.new
|
|
17
17
|
@logger = stub_everything
|
|
18
|
-
@config = stub(:logger => @logger)
|
|
18
|
+
@config = stub(:logger => @logger, :debug= => nil, :dry_run= => nil, :preserve_roles= => nil)
|
|
19
19
|
@config.stubs(:set)
|
|
20
20
|
@config.stubs(:load)
|
|
21
21
|
@config.stubs(:trigger)
|
|
@@ -129,4 +129,4 @@ class CLIExecuteTest < Test::Unit::TestCase
|
|
|
129
129
|
MockCLI.expects(:parse).with(ARGV).returns(cli)
|
|
130
130
|
MockCLI.execute
|
|
131
131
|
end
|
|
132
|
-
end
|
|
132
|
+
end
|
data/test/cli/help_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "utils"
|
|
2
2
|
require 'capistrano/cli/help'
|
|
3
3
|
|
|
4
4
|
class CLIHelpTest < Test::Unit::TestCase
|
|
@@ -33,7 +33,7 @@ class CLIHelpTest < Test::Unit::TestCase
|
|
|
33
33
|
|
|
34
34
|
def test_execute_requested_actions_with_tasks_should_call_task_list
|
|
35
35
|
@cli.options[:tasks] = true
|
|
36
|
-
@cli.expects(:task_list).with(:config)
|
|
36
|
+
@cli.expects(:task_list).with(:config, true)
|
|
37
37
|
@cli.expects(:explain_task).never
|
|
38
38
|
@cli.execute_requested_actions(:config)
|
|
39
39
|
assert !@cli.called_original
|
|
@@ -57,13 +57,38 @@ class CLIHelpTest < Test::Unit::TestCase
|
|
|
57
57
|
expected_max_len = 80 - 3 - MockCLI::LINE_PADDING
|
|
58
58
|
task_list = [task("c"), task("g", "c:g"), task("b", "c:b"), task("a")]
|
|
59
59
|
task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name) }
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
config = mock("config")
|
|
62
62
|
config.expects(:task_list).with(:all).returns(task_list)
|
|
63
63
|
@cli.stubs(:puts)
|
|
64
64
|
@cli.task_list(config)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def test_task_list_should_query_tasks_with_pattern
|
|
68
|
+
expected_max_len = 80 - 3 - MockCLI::LINE_PADDING
|
|
69
|
+
task_list = [task("g", "c:g"), task("b", "c:b")]
|
|
70
|
+
task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name)}
|
|
71
|
+
|
|
72
|
+
config = mock("config")
|
|
73
|
+
config.expects(:task_list).with(:all).once.returns(task_list)
|
|
74
|
+
|
|
75
|
+
@cli.stubs(:puts)
|
|
76
|
+
@cli.task_list(config, "c")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_task_list_should_query_for_all_tasks_when_pattern_doesnt_match
|
|
80
|
+
expected_max_len = 80 - 3 - MockCLI::LINE_PADDING
|
|
81
|
+
task_list = [task("g", "c:g"), task("b", "c:b")]
|
|
82
|
+
task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name) }
|
|
83
|
+
|
|
84
|
+
config = mock("config")
|
|
85
|
+
config.expects(:task_list).with(:all).times(2).returns(task_list)
|
|
86
|
+
|
|
87
|
+
@cli.stubs(:warn)
|
|
88
|
+
@cli.stubs(:puts)
|
|
89
|
+
@cli.task_list(config, "z")
|
|
90
|
+
end
|
|
91
|
+
|
|
67
92
|
def test_task_list_should_never_use_less_than_MIN_MAX_LEN_chars_for_descriptions
|
|
68
93
|
@ui.stubs(:output_cols).returns(20)
|
|
69
94
|
t = task("c")
|
|
@@ -133,7 +158,8 @@ class CLIHelpTest < Test::Unit::TestCase
|
|
|
133
158
|
|
|
134
159
|
private
|
|
135
160
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
161
|
+
def task(name, fqn=name, desc="a description")
|
|
162
|
+
stub("task", :name => name, :fully_qualified_name => fqn, :description => desc)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
end
|
data/test/cli/options_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "utils"
|
|
2
2
|
require 'capistrano/cli/options'
|
|
3
3
|
|
|
4
4
|
class CLIOptionsTest < Test::Unit::TestCase
|
|
@@ -23,7 +23,25 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|
|
23
23
|
@cli.expects(:exit).raises(ExitException)
|
|
24
24
|
assert_raises(ExitException) { @cli.parse_options! }
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
def test_parse_options_with_d_should_set_debug_option
|
|
28
|
+
@cli.args << "-d"
|
|
29
|
+
@cli.parse_options!
|
|
30
|
+
assert @cli.options[:debug]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_parse_options_with_n_should_set_dry_run_option
|
|
34
|
+
@cli.args << "-n"
|
|
35
|
+
@cli.parse_options!
|
|
36
|
+
assert @cli.options[:dry_run]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_parse_options_with_dry_run_should_set_dry_run_option
|
|
40
|
+
@cli.args << "--dry-run"
|
|
41
|
+
@cli.parse_options!
|
|
42
|
+
assert @cli.options[:dry_run]
|
|
43
|
+
end
|
|
44
|
+
|
|
27
45
|
def test_parse_options_with_e_should_set_explain_option
|
|
28
46
|
@cli.args << "-e" << "sample"
|
|
29
47
|
@cli.parse_options!
|
|
@@ -75,18 +93,102 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|
|
75
93
|
assert_equal 0, @cli.options[:verbose]
|
|
76
94
|
end
|
|
77
95
|
|
|
96
|
+
def test_parse_options_with_r_should_set_preserve_roles_option
|
|
97
|
+
@cli.args << "-r"
|
|
98
|
+
@cli.parse_options!
|
|
99
|
+
assert @cli.options[:preserve_roles]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_parse_options_with_preserve_roles_should_set_preserve_roles_option
|
|
103
|
+
@cli.args << "--preserve-roles"
|
|
104
|
+
@cli.parse_options!
|
|
105
|
+
assert @cli.options[:preserve_roles]
|
|
106
|
+
end
|
|
107
|
+
|
|
78
108
|
def test_parse_options_with_S_should_set_pre_vars
|
|
79
109
|
@cli.args << "-S" << "foo=bar"
|
|
80
110
|
@cli.parse_options!
|
|
81
111
|
assert_equal "bar", @cli.options[:pre_vars][:foo]
|
|
82
112
|
end
|
|
83
113
|
|
|
114
|
+
def test_S_should_coerce_digits_to_integers
|
|
115
|
+
@cli.args << "-S" << "foo=1234"
|
|
116
|
+
@cli.parse_options!
|
|
117
|
+
assert_equal 1234, @cli.options[:pre_vars][:foo]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_S_should_treat_quoted_integers_as_string
|
|
121
|
+
@cli.args << "-S" << "foo=\"1234\""
|
|
122
|
+
@cli.parse_options!
|
|
123
|
+
assert_equal "1234", @cli.options[:pre_vars][:foo]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_S_should_treat_digits_with_dot_as_floating_point
|
|
127
|
+
@cli.args << "-S" << "foo=3.1415"
|
|
128
|
+
@cli.parse_options!
|
|
129
|
+
assert_equal 3.1415, @cli.options[:pre_vars][:foo]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_S_should_treat_true_as_boolean_true
|
|
133
|
+
@cli.args << "-S" << "foo=true"
|
|
134
|
+
@cli.parse_options!
|
|
135
|
+
assert_equal true, @cli.options[:pre_vars][:foo]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_S_should_treat_false_as_boolean_false
|
|
139
|
+
@cli.args << "-S" << "foo=false"
|
|
140
|
+
@cli.parse_options!
|
|
141
|
+
assert_equal false, @cli.options[:pre_vars][:foo]
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_S_should_treat_nil_as_nil
|
|
145
|
+
@cli.args << "-S" << "foo=nil"
|
|
146
|
+
@cli.parse_options!
|
|
147
|
+
assert_equal nil, @cli.options[:pre_vars][:foo]
|
|
148
|
+
end
|
|
149
|
+
|
|
84
150
|
def test_parse_options_with_s_should_set_vars
|
|
85
151
|
@cli.args << "-s" << "foo=bar"
|
|
86
152
|
@cli.parse_options!
|
|
87
153
|
assert_equal "bar", @cli.options[:vars][:foo]
|
|
88
154
|
end
|
|
89
155
|
|
|
156
|
+
def test_s_should_coerce_digits_to_integers
|
|
157
|
+
@cli.args << "-s" << "foo=1234"
|
|
158
|
+
@cli.parse_options!
|
|
159
|
+
assert_equal 1234, @cli.options[:vars][:foo]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def test_s_should_treat_quoted_integers_as_string
|
|
163
|
+
@cli.args << "-s" << "foo=\"1234\""
|
|
164
|
+
@cli.parse_options!
|
|
165
|
+
assert_equal "1234", @cli.options[:vars][:foo]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def test_s_should_treat_digits_with_dot_as_floating_point
|
|
169
|
+
@cli.args << "-s" << "foo=3.1415"
|
|
170
|
+
@cli.parse_options!
|
|
171
|
+
assert_equal 3.1415, @cli.options[:vars][:foo]
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_s_should_treat_true_as_boolean_true
|
|
175
|
+
@cli.args << "-s" << "foo=true"
|
|
176
|
+
@cli.parse_options!
|
|
177
|
+
assert_equal true, @cli.options[:vars][:foo]
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def test_s_should_treat_false_as_boolean_false
|
|
181
|
+
@cli.args << "-s" << "foo=false"
|
|
182
|
+
@cli.parse_options!
|
|
183
|
+
assert_equal false, @cli.options[:vars][:foo]
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_s_should_treat_nil_as_nil
|
|
187
|
+
@cli.args << "-s" << "foo=nil"
|
|
188
|
+
@cli.parse_options!
|
|
189
|
+
assert_equal nil, @cli.options[:vars][:foo]
|
|
190
|
+
end
|
|
191
|
+
|
|
90
192
|
def test_parse_options_with_T_should_set_tasks_option_and_set_verbose_off
|
|
91
193
|
@cli.args << "-T"
|
|
92
194
|
@cli.parse_options!
|
|
@@ -96,7 +198,7 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|
|
96
198
|
|
|
97
199
|
def test_parse_options_with_V_should_show_version_and_exit
|
|
98
200
|
@cli.args << "-V"
|
|
99
|
-
@cli.expects(:puts).with { |s| s.include?(Capistrano::Version
|
|
201
|
+
@cli.expects(:puts).with { |s| s.include?(Capistrano::Version.to_s) }
|
|
100
202
|
@cli.expects(:exit).raises(ExitException)
|
|
101
203
|
assert_raises(ExitException) { @cli.parse_options! }
|
|
102
204
|
end
|
|
@@ -171,7 +273,8 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|
|
171
273
|
assert_equal "world", ENV["HELLO"]
|
|
172
274
|
assert_equal "value", ENV["ANOTHER"]
|
|
173
275
|
ensure
|
|
174
|
-
ENV
|
|
276
|
+
ENV.delete("HELLO")
|
|
277
|
+
ENV.delete("ANOTHER")
|
|
175
278
|
end
|
|
176
279
|
|
|
177
280
|
def test_remaining_args_should_be_added_to_actions_list
|
|
@@ -179,7 +282,7 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|
|
179
282
|
@cli.parse_options!
|
|
180
283
|
assert_equal %w(something else), @cli.args
|
|
181
284
|
ensure
|
|
182
|
-
ENV
|
|
285
|
+
ENV.delete("HELLO")
|
|
183
286
|
end
|
|
184
287
|
|
|
185
288
|
def test_search_for_default_recipe_file_should_look_for_Capfile
|
|
@@ -223,4 +326,4 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|
|
223
326
|
MockCLI.expects(:new).with(%w(a b c)).returns(cli)
|
|
224
327
|
assert_equal cli, MockCLI.parse(%w(a b c))
|
|
225
328
|
end
|
|
226
|
-
end
|
|
329
|
+
end
|
data/test/cli/ui_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "utils"
|
|
2
2
|
require 'capistrano/cli/ui'
|
|
3
3
|
|
|
4
4
|
class CLIUITest < Test::Unit::TestCase
|
|
@@ -25,4 +25,4 @@ class CLIUITest < Test::Unit::TestCase
|
|
|
25
25
|
MockCLI.expects(:ui).returns(ui)
|
|
26
26
|
assert_equal "sayuncle", MockCLI.password_prompt("Give the passphrase: ")
|
|
27
27
|
end
|
|
28
|
-
end
|
|
28
|
+
end
|
data/test/cli_test.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "utils"
|
|
2
2
|
require 'capistrano/cli'
|
|
3
3
|
|
|
4
4
|
class CLI_Test < Test::Unit::TestCase
|
|
5
5
|
def test_options_ui_and_help_modules_should_integrate_successfully_with_configuration
|
|
6
|
-
cli = Capistrano::CLI.parse(%w(-T))
|
|
6
|
+
cli = Capistrano::CLI.parse(%w(-T -x -X))
|
|
7
7
|
cli.expects(:puts).at_least_once
|
|
8
8
|
cli.execute!
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def test_options_and_execute_modules_should_integrate_successfully_with_configuration
|
|
12
12
|
path = "#{File.dirname(__FILE__)}/fixtures/cli_integration.rb"
|
|
13
|
-
cli = Capistrano::CLI.parse(%W(-q -f #{path} testing))
|
|
13
|
+
cli = Capistrano::CLI.parse(%W(-x -X -q -f #{path} testing))
|
|
14
14
|
config = cli.execute!
|
|
15
15
|
assert config[:testing_occurred]
|
|
16
16
|
end
|