capistrano 2.15.11 → 3.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +17 -8
  3. data/Gemfile +1 -12
  4. data/LICENSE.txt +18 -0
  5. data/README.md +65 -68
  6. data/Rakefile +4 -10
  7. data/bin/cap +2 -3
  8. data/bin/capify +7 -91
  9. data/capistrano.gemspec +20 -34
  10. data/lib/Capfile +2 -0
  11. data/lib/capistrano/application.rb +28 -0
  12. data/lib/capistrano/bundler.rb +1 -0
  13. data/lib/capistrano/configuration/question.rb +42 -0
  14. data/lib/capistrano/configuration/server.rb +24 -0
  15. data/lib/capistrano/configuration/servers.rb +43 -95
  16. data/lib/capistrano/configuration.rb +81 -44
  17. data/lib/capistrano/console.rb +1 -0
  18. data/lib/capistrano/defaults.rb +11 -0
  19. data/lib/capistrano/deploy.rb +3 -0
  20. data/lib/capistrano/dotfile.rb +3 -0
  21. data/lib/capistrano/dsl/env.rb +57 -0
  22. data/lib/capistrano/dsl/paths.rb +74 -0
  23. data/lib/capistrano/dsl/stages.rb +15 -0
  24. data/lib/capistrano/dsl/task_enhancements.rb +15 -0
  25. data/lib/capistrano/dsl.rb +38 -0
  26. data/lib/capistrano/git.rb +1 -0
  27. data/lib/capistrano/i18n.rb +33 -0
  28. data/lib/capistrano/install.rb +1 -0
  29. data/lib/capistrano/setup.rb +17 -0
  30. data/lib/capistrano/tasks/bundler.rake +13 -0
  31. data/lib/capistrano/tasks/console.rake +21 -0
  32. data/lib/capistrano/tasks/deploy.rake +153 -0
  33. data/lib/capistrano/tasks/framework.rake +45 -0
  34. data/lib/capistrano/tasks/git.rake +65 -0
  35. data/lib/capistrano/tasks/install.rake +39 -0
  36. data/lib/capistrano/templates/Capfile +43 -0
  37. data/lib/capistrano/templates/deploy.rb.erb +17 -0
  38. data/lib/capistrano/templates/stage.rb.erb +20 -0
  39. data/lib/capistrano/version.rb +1 -11
  40. data/lib/capistrano.rb +9 -3
  41. data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
  42. data/spec/lib/capistrano/configuration/server_spec.rb +48 -0
  43. data/spec/lib/capistrano/configuration/servers_spec.rb +79 -0
  44. data/spec/lib/capistrano/configuration_spec.rb +80 -0
  45. data/spec/lib/capistrano/dsl/env_spec.rb +83 -0
  46. data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
  47. data/spec/lib/capistrano/dsl_spec.rb +51 -0
  48. data/spec/lib/capistrano_spec.rb +8 -0
  49. data/spec/spec_helper.rb +14 -0
  50. metadata +89 -215
  51. data/.travis.yml +0 -9
  52. data/CHANGELOG +0 -1203
  53. data/lib/capistrano/callback.rb +0 -45
  54. data/lib/capistrano/cli/execute.rb +0 -85
  55. data/lib/capistrano/cli/help.rb +0 -125
  56. data/lib/capistrano/cli/help.txt +0 -81
  57. data/lib/capistrano/cli/options.rb +0 -243
  58. data/lib/capistrano/cli/ui.rb +0 -40
  59. data/lib/capistrano/cli.rb +0 -47
  60. data/lib/capistrano/command.rb +0 -303
  61. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -50
  62. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  63. data/lib/capistrano/configuration/actions/invocation.rb +0 -329
  64. data/lib/capistrano/configuration/alias_task.rb +0 -26
  65. data/lib/capistrano/configuration/callbacks.rb +0 -147
  66. data/lib/capistrano/configuration/connections.rb +0 -237
  67. data/lib/capistrano/configuration/execution.rb +0 -142
  68. data/lib/capistrano/configuration/loading.rb +0 -205
  69. data/lib/capistrano/configuration/log_formatters.rb +0 -75
  70. data/lib/capistrano/configuration/namespaces.rb +0 -223
  71. data/lib/capistrano/configuration/roles.rb +0 -83
  72. data/lib/capistrano/configuration/variables.rb +0 -127
  73. data/lib/capistrano/errors.rb +0 -19
  74. data/lib/capistrano/ext/multistage.rb +0 -67
  75. data/lib/capistrano/ext/string.rb +0 -5
  76. data/lib/capistrano/extensions.rb +0 -57
  77. data/lib/capistrano/fix_rake_deprecated_dsl.rb +0 -8
  78. data/lib/capistrano/logger.rb +0 -166
  79. data/lib/capistrano/processable.rb +0 -55
  80. data/lib/capistrano/recipes/compat.rb +0 -32
  81. data/lib/capistrano/recipes/deploy/assets.rb +0 -202
  82. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  83. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
  84. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -117
  85. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  86. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -200
  87. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  88. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
  89. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
  90. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -299
  91. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
  92. data/lib/capistrano/recipes/deploy/scm/none.rb +0 -55
  93. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -152
  94. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
  95. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  96. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -92
  97. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  98. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -338
  99. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  100. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  101. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
  102. data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +0 -21
  103. data/lib/capistrano/recipes/deploy/strategy.rb +0 -20
  104. data/lib/capistrano/recipes/deploy.rb +0 -625
  105. data/lib/capistrano/recipes/standard.rb +0 -37
  106. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  107. data/lib/capistrano/role.rb +0 -102
  108. data/lib/capistrano/server_definition.rb +0 -56
  109. data/lib/capistrano/shell.rb +0 -265
  110. data/lib/capistrano/ssh.rb +0 -95
  111. data/lib/capistrano/task_definition.rb +0 -77
  112. data/lib/capistrano/transfer.rb +0 -218
  113. data/test/cli/execute_test.rb +0 -132
  114. data/test/cli/help_test.rb +0 -165
  115. data/test/cli/options_test.rb +0 -329
  116. data/test/cli/ui_test.rb +0 -28
  117. data/test/cli_test.rb +0 -17
  118. data/test/command_test.rb +0 -322
  119. data/test/configuration/actions/file_transfer_test.rb +0 -61
  120. data/test/configuration/actions/inspect_test.rb +0 -76
  121. data/test/configuration/actions/invocation_test.rb +0 -306
  122. data/test/configuration/alias_task_test.rb +0 -118
  123. data/test/configuration/callbacks_test.rb +0 -201
  124. data/test/configuration/connections_test.rb +0 -439
  125. data/test/configuration/execution_test.rb +0 -175
  126. data/test/configuration/loading_test.rb +0 -148
  127. data/test/configuration/namespace_dsl_test.rb +0 -332
  128. data/test/configuration/roles_test.rb +0 -157
  129. data/test/configuration/servers_test.rb +0 -183
  130. data/test/configuration/variables_test.rb +0 -190
  131. data/test/configuration_test.rb +0 -77
  132. data/test/deploy/local_dependency_test.rb +0 -76
  133. data/test/deploy/remote_dependency_test.rb +0 -146
  134. data/test/deploy/scm/accurev_test.rb +0 -23
  135. data/test/deploy/scm/base_test.rb +0 -55
  136. data/test/deploy/scm/bzr_test.rb +0 -51
  137. data/test/deploy/scm/darcs_test.rb +0 -37
  138. data/test/deploy/scm/git_test.rb +0 -274
  139. data/test/deploy/scm/mercurial_test.rb +0 -134
  140. data/test/deploy/scm/none_test.rb +0 -35
  141. data/test/deploy/scm/perforce_test.rb +0 -23
  142. data/test/deploy/scm/subversion_test.rb +0 -68
  143. data/test/deploy/strategy/copy_test.rb +0 -360
  144. data/test/extensions_test.rb +0 -69
  145. data/test/fixtures/cli_integration.rb +0 -5
  146. data/test/fixtures/config.rb +0 -5
  147. data/test/fixtures/custom.rb +0 -3
  148. data/test/logger_formatting_test.rb +0 -149
  149. data/test/logger_test.rb +0 -134
  150. data/test/recipes_test.rb +0 -25
  151. data/test/role_test.rb +0 -11
  152. data/test/server_definition_test.rb +0 -121
  153. data/test/shell_test.rb +0 -96
  154. data/test/ssh_test.rb +0 -113
  155. data/test/task_definition_test.rb +0 -117
  156. data/test/transfer_test.rb +0 -168
  157. data/test/utils.rb +0 -37
  158. data/test/version_test.rb +0 -11
@@ -1,146 +0,0 @@
1
- require "utils"
2
- require 'capistrano/recipes/deploy/remote_dependency'
3
-
4
- class RemoteDependencyTest < Test::Unit::TestCase
5
- def setup
6
- @config = { }
7
- @dependency = Capistrano::Deploy::RemoteDependency.new(@config)
8
- end
9
-
10
- def test_should_use_standard_error_message_for_directory
11
- setup_for_a_configuration_run("test -d /data", false)
12
- @dependency.directory("/data")
13
- assert_equal "`/data' is not a directory (host)", @dependency.message
14
- end
15
-
16
- def test_should_use_standard_error_message_for_file
17
- setup_for_a_configuration_run("test -f /data/foo.txt", false)
18
- @dependency.file("/data/foo.txt")
19
- assert_equal "`/data/foo.txt' is not a file (host)", @dependency.message
20
- end
21
-
22
- def test_should_use_standard_error_message_for_writable
23
- setup_for_a_configuration_run("test -w /data/foo.txt", false)
24
- @dependency.writable("/data/foo.txt")
25
- assert_equal "`/data/foo.txt' is not writable (host)", @dependency.message
26
- end
27
-
28
- def test_should_use_standard_error_message_for_command
29
- setup_for_a_configuration_run("which cat", false)
30
- @dependency.command("cat")
31
- assert_equal "`cat' could not be found in the path (host)", @dependency.message
32
- end
33
-
34
- def test_should_use_standard_error_message_for_gem
35
- setup_for_a_configuration_gem_run("capistrano", "9.9", false)
36
- @dependency.gem("capistrano", 9.9)
37
- assert_equal "gem `capistrano' 9.9 could not be found (host)", @dependency.message
38
- end
39
-
40
- def test_should_use_standard_error_message_for_deb
41
- setup_for_a_configuration_deb_run("dpkg", "1.15", false)
42
- @dependency.deb("dpkg", "1.15")
43
- assert_equal "package `dpkg' 1.15 could not be found (host)", @dependency.message
44
- end
45
-
46
- def test_should_use_standard_error_message_for_rpm
47
- setup_for_a_configuration_rpm_run("rpm", "4.8", false)
48
- @dependency.rpm("rpm", "4.8")
49
- assert_equal "package `rpm' 4.8 could not be found (host)", @dependency.message
50
- end
51
-
52
- def test_should_fail_if_directory_not_found
53
- setup_for_a_configuration_run("test -d /data", false)
54
- assert !@dependency.directory("/data").pass?
55
- end
56
-
57
- def test_should_pass_if_directory_found
58
- setup_for_a_configuration_run("test -d /data", true)
59
- assert @dependency.directory("/data").pass?
60
- end
61
-
62
- def test_should_fail_if_file_not_found
63
- setup_for_a_configuration_run("test -f /data/foo.txt", false)
64
- assert !@dependency.file("/data/foo.txt").pass?
65
- end
66
-
67
- def test_should_pass_if_file_found
68
- setup_for_a_configuration_run("test -f /data/foo.txt", true)
69
- assert @dependency.file("/data/foo.txt").pass?
70
- end
71
-
72
- def test_should_fail_if_writable_not_found
73
- setup_for_a_configuration_run("test -w /data/foo.txt", false)
74
- assert !@dependency.writable("/data/foo.txt").pass?
75
- end
76
-
77
- def test_should_pass_if_writable_found
78
- setup_for_a_configuration_run("test -w /data/foo.txt", true)
79
- assert @dependency.writable("/data/foo.txt").pass?
80
- end
81
-
82
- def test_should_fail_if_command_not_found
83
- setup_for_a_configuration_run("which cat", false)
84
- assert !@dependency.command("cat").pass?
85
- end
86
-
87
- def test_should_pass_if_command_found
88
- setup_for_a_configuration_run("which cat", true)
89
- assert @dependency.command("cat").pass?
90
- end
91
-
92
- def test_should_fail_if_gem_not_found
93
- setup_for_a_configuration_gem_run("capistrano", "9.9", false)
94
- assert !@dependency.gem("capistrano", 9.9).pass?
95
- end
96
-
97
- def test_should_pass_if_gem_found
98
- setup_for_a_configuration_gem_run("capistrano", "9.9", true)
99
- assert @dependency.gem("capistrano", 9.9).pass?
100
- end
101
-
102
- def test_should_pass_if_deb_found
103
- setup_for_a_configuration_deb_run("dpkg", "1.15", true)
104
- assert @dependency.deb("dpkg", "1.15").pass?
105
- end
106
-
107
- def test_should_fail_if_deb_not_found
108
- setup_for_a_configuration_deb_run("dpkg", "1.15", false)
109
- assert !@dependency.deb("dpkg", "1.15").pass?
110
- end
111
-
112
- def test_should_use_alternative_message_if_provided
113
- setup_for_a_configuration_run("which cat", false)
114
- @dependency.command("cat").or("Sorry")
115
- assert_equal "Sorry (host)", @dependency.message
116
- end
117
-
118
- private
119
-
120
- def setup_for_a_configuration_run(command, passing)
121
- expectation = @config.expects(:invoke_command).with(command, {})
122
- if passing
123
- expectation.returns(true)
124
- else
125
- error = Capistrano::CommandError.new
126
- error.expects(:hosts).returns(["host"])
127
- expectation.raises(error)
128
- end
129
- end
130
-
131
- def setup_for_a_configuration_gem_run(name, version, passing)
132
- @config.expects(:fetch).with(:gem_command, "gem").returns("gem")
133
- find_gem_cmd = "gem specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'"
134
- setup_for_a_configuration_run(find_gem_cmd, passing)
135
- end
136
-
137
- def setup_for_a_configuration_deb_run(name, version, passing)
138
- find_deb_cmd = "dpkg -s #{name} | grep '^Version: #{version}'"
139
- setup_for_a_configuration_run(find_deb_cmd, passing)
140
- end
141
-
142
- def setup_for_a_configuration_rpm_run(name, version, passing)
143
- find_rpm_cmd = "rpm -q #{name} | grep '#{version}'"
144
- setup_for_a_configuration_run(find_rpm_cmd, passing)
145
- end
146
- end
@@ -1,23 +0,0 @@
1
- require "utils"
2
- require 'capistrano/recipes/deploy/scm/accurev'
3
-
4
- class AccurevTest < Test::Unit::TestCase
5
- include Capistrano::Deploy::SCM
6
-
7
- def test_internal_revision_to_s
8
- assert_equal 'foo/1', Accurev::InternalRevision.new('foo', 1).to_s
9
- assert_equal 'foo/highest', Accurev::InternalRevision.new('foo', 'highest').to_s
10
- end
11
-
12
- def test_internal_revision_parse
13
- revision = Accurev::InternalRevision.parse('foo')
14
- assert_equal 'foo', revision.stream
15
- assert_equal 'highest', revision.transaction_id
16
- assert_equal 'foo/highest', revision.to_s
17
-
18
- revision = Accurev::InternalRevision.parse('foo/1')
19
- assert_equal 'foo', revision.stream
20
- assert_equal '1', revision.transaction_id
21
- assert_equal 'foo/1', revision.to_s
22
- end
23
- end
@@ -1,55 +0,0 @@
1
- require "utils"
2
- require 'capistrano/recipes/deploy/scm/base'
3
-
4
- class DeploySCMBaseTest < Test::Unit::TestCase
5
- class TestSCM < Capistrano::Deploy::SCM::Base
6
- default_command "floopy"
7
- end
8
-
9
- def setup
10
- @config = { }
11
- def @config.exists?(name); key?(name); end
12
-
13
- @source = TestSCM.new(@config)
14
- end
15
-
16
- def test_command_should_default_to_default_command
17
- assert_equal "floopy", @source.command
18
- @source.local { assert_equal "floopy", @source.command }
19
- end
20
-
21
- def test_command_should_use_scm_command_if_available
22
- @config[:scm_command] = "/opt/local/bin/floopy"
23
- assert_equal "/opt/local/bin/floopy", @source.command
24
- end
25
-
26
- def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
27
- @config[:scm_command] = "/opt/local/bin/floopy"
28
- @source.local { assert_equal "/opt/local/bin/floopy", @source.command }
29
- end
30
-
31
- def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
32
- @config[:scm_command] = "/opt/local/bin/floopy"
33
- @config[:local_scm_command] = "/usr/local/bin/floopy"
34
- assert_equal "/opt/local/bin/floopy", @source.command
35
- @source.local { assert_equal "/usr/local/bin/floopy", @source.command }
36
- end
37
-
38
- def test_command_should_use_default_if_scm_command_is_default
39
- @config[:scm_command] = :default
40
- assert_equal "floopy", @source.command
41
- end
42
-
43
- def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
44
- @config[:scm_command] = "/foo/bar/floopy"
45
- @config[:local_scm_command] = :default
46
- @source.local { assert_equal "floopy", @source.command }
47
- end
48
-
49
- def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
50
- @config[:scm_command] = "/foo/bar/floopy"
51
- @config[:local_scm_command] = :default
52
- assert_equal "floopy", @source.local.command
53
- assert_equal "/foo/bar/floopy", @source.command
54
- end
55
- end
@@ -1,51 +0,0 @@
1
- require "utils"
2
- require 'capistrano/recipes/deploy/scm/bzr'
3
-
4
- class DeploySCMBzrTest < Test::Unit::TestCase
5
- class TestSCM < Capistrano::Deploy::SCM::Bzr
6
- default_command "bzr"
7
- end
8
-
9
- def setup
10
- @config = { :repository => "." }
11
-
12
- def @config.exists?(name); key?(name); end # is this actually needed?
13
-
14
- @source = TestSCM.new(@config)
15
- end
16
-
17
- # The bzr scm does not support pseudo-ids. The bzr adapter uses symbol :head
18
- # to refer to the recently committed revision.
19
- def test_head_revision
20
- assert_equal(:head,
21
- @source.head,
22
- "Since bzr doesn't know a real head revision, symbol :head is used instead.")
23
- end
24
-
25
- # The bzr scm does support many different ways to specify a revision. Only
26
- # symbol :head triggers the bzr command 'revno'.
27
- def test_query_revision
28
- assert_equal("bzr revno #{@config[:repository]}",
29
- @source.query_revision(:head) { |o| o },
30
- "Query for :head revision should call bzr command 'revno' in repository directory.")
31
-
32
- # Many valid revision specifications, some invalid on the last line
33
- revision_samples = [ 5, -7, '2', '-4',
34
- 'revid:revid:aaaa@bbbb-123456789',
35
- 'submit:',
36
- 'ancestor:/path/to/branch',
37
- 'date:yesterday',
38
- 'branch:/path/to/branch',
39
- 'tag:trunk',
40
- 'revno:3:/path/to/branch',
41
- 'before:revid:aaaa@bbbb-1234567890',
42
- 'last:3',
43
- nil, {}, [], true, false, 1.34, ]
44
-
45
- revision_samples.each do |revivsion_spec|
46
- assert_equal(revivsion_spec,
47
- @source.query_revision(revivsion_spec),
48
- "Any revision specification other than symbol :head should simply by returned.")
49
- end
50
- end
51
- end
@@ -1,37 +0,0 @@
1
- require "utils"
2
- require 'capistrano/recipes/deploy/scm/darcs'
3
-
4
- class DeploySCMDarcsTest < Test::Unit::TestCase
5
- class TestSCM < Capistrano::Deploy::SCM::Darcs
6
- default_command "darcs"
7
- end
8
- def setup
9
- @config = { :repository => "." }
10
- # def @config.exists?(name); key?(name); end
11
-
12
- @source = TestSCM.new(@config)
13
- end
14
-
15
- # We should be able to pick a specific hash.
16
- def test_checkout_hash
17
- hsh = "*version_hash*"
18
- assert_match(%r{--to-match=.hash #{Regexp.quote(hsh)}},
19
- @source.checkout(hsh, "*foo_location*"),
20
- "Specifying a revision hash got the --to-match option wrong.")
21
- end
22
-
23
- # Picking the head revision should leave out the hash, because head is the
24
- # default and we don't have a HEAD pseudotag
25
- def test_checkout_head
26
- hsh = @source.head
27
- assert_no_match(%r{--to-match}, @source.checkout(hsh, "*foo_location*"),
28
- "Selecting the head revision incorrectly produced a --to-match option.")
29
- end
30
-
31
- # Leaving the revision as nil shouldn't break anything.
32
- def test_checkout_nil
33
- assert_no_match(%r{--to-match}, @source.checkout(nil, "*foo_location*"),
34
- "Leaving the revision as nil incorrectly produced a --to-match option.")
35
- end
36
- end
37
-
@@ -1,274 +0,0 @@
1
- require "utils"
2
- require 'capistrano/recipes/deploy/scm/git'
3
-
4
- class DeploySCMGitTest < Test::Unit::TestCase
5
- class TestSCM < Capistrano::Deploy::SCM::Git
6
- default_command "git"
7
- end
8
-
9
- def setup
10
- @config = { :repository => "." }
11
- def @config.exists?(name); key?(name); end
12
-
13
- @source = TestSCM.new(@config)
14
- end
15
-
16
- def test_head
17
- assert_equal "HEAD", @source.head
18
-
19
- # With :branch
20
- @config[:branch] = "master"
21
- assert_equal "master", @source.head
22
- end
23
-
24
- def test_origin
25
- assert_equal "origin", @source.origin
26
- @config[:remote] = "username"
27
- assert_equal "username", @source.origin
28
- end
29
-
30
- def test_checkout
31
- @config[:repository] = "git@somehost.com:project.git"
32
- dest = "/var/www"
33
- rev = 'c2d9e79'
34
- assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
35
-
36
- # With :scm_command
37
- git = "/opt/local/bin/git"
38
- @config[:scm_command] = git
39
- assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev}", @source.checkout(rev, dest).gsub(/\s+/, ' ')
40
-
41
- # with submodules
42
- @config[:git_enable_submodules] = true
43
- assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && export GIT_RECURSIVE=$([ ! \"`#{git} --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && #{git} submodule -q update --init $GIT_RECURSIVE", @source.checkout(rev, dest).gsub(/\s+/, ' ')
44
- end
45
-
46
- def test_checkout_branching
47
- @config[:repository] = "git@somehost.com:project.git"
48
- dest = "/var/www"
49
- rev = 'c2d9e79'
50
- assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy c2d9e79", @source.checkout(rev, dest)
51
-
52
- # with :branch
53
- @config[:branch] = "master"
54
- assert_equal "git clone -q -b master git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy c2d9e79", @source.checkout(rev, dest)
55
-
56
- # with :branch with hash code
57
- @config[:branch] = "c2d9e79"
58
- assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy c2d9e79", @source.checkout(rev, dest)
59
- end
60
-
61
- def test_checkout_submodules_without_recursive
62
- @config[:repository] = "git@somehost.com:project.git"
63
- dest = "/var/www"
64
- rev = 'c2d9e79'
65
- @config[:git_enable_submodules] = true
66
- @config[:git_submodules_recursive] = false
67
- assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update --init", @source.checkout(rev, dest).gsub(/\s+/, ' ')
68
- end
69
-
70
- def test_checkout_with_verbose_should_not_use_q_switch
71
- @config[:repository] = "git@somehost.com:project.git"
72
- @config[:scm_verbose] = true
73
- dest = "/var/www"
74
- rev = 'c2d9e79'
75
- assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)
76
- end
77
-
78
- def test_checkout_with_verbose_off_should_use_q_switch
79
- @config[:repository] = "git@somehost.com:project.git"
80
- @config[:scm_verbose] = false
81
- dest = "/var/www"
82
- rev = 'c2d9e79'
83
- assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
84
- end
85
-
86
- def test_diff
87
- assert_equal "git diff master", @source.diff('master')
88
- assert_equal "git diff master..branch", @source.diff('master', 'branch')
89
- end
90
-
91
- def test_log
92
- assert_equal "git log master..", @source.log('master')
93
- assert_equal "git log master..branch", @source.log('master', 'branch')
94
- end
95
-
96
- def test_query_revision_from_remote
97
- revision = @source.query_revision('HEAD') do |o|
98
- assert_equal "git ls-remote . HEAD", o
99
- "d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD"
100
- end
101
- assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
102
- end
103
-
104
- def test_query_revision_falls_back_to_local
105
- revision = @source.query_revision('d11006') do |o|
106
- return nil if o == "git ls-remote . d11006"
107
- assert_equal "git rev-parse --revs-only d11006", o
108
- "d11006102c07c94e5d54dd0ee63dca825c93ed61"
109
- end
110
- assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
111
- end
112
-
113
- def test_query_revision_has_whitespace
114
- revision = @source.query_revision('HEAD') do |o|
115
- assert_equal "git ls-remote . HEAD", o
116
- "d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD\r"
117
- end
118
- assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
119
- end
120
-
121
- def test_query_revision_deprecation_error
122
- assert_raise(ArgumentError) do
123
- revision = @source.query_revision('origin/release') {}
124
- end
125
- end
126
-
127
- def test_command_should_be_backwards_compatible
128
- # 1.x version of this module used ":git", not ":scm_command"
129
- @config[:git] = "/srv/bin/git"
130
- assert_equal "/srv/bin/git", @source.command
131
- end
132
-
133
- def test_sync
134
- dest = "/var/www"
135
- rev = 'c2d9e79'
136
- assert_equal "cd #{dest} && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest)
137
-
138
- # With :scm_command
139
- git = "/opt/local/bin/git"
140
- @config[:scm_command] = git
141
- assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} fetch --tags -q origin && #{git} reset -q --hard #{rev} && #{git} clean -q -d -x -f", @source.sync(rev, dest)
142
-
143
- # with submodules
144
- @config[:git_enable_submodules] = true
145
- assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} fetch --tags -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && #{git} submodule -q sync && export GIT_RECURSIVE=$([ ! \"`#{git} --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && #{git} submodule -q update --init $GIT_RECURSIVE && #{git} clean -q -d -x -f", @source.sync(rev, dest)
146
- end
147
-
148
- def test_sync_with_remote
149
- dest = "/var/www"
150
- rev = 'c2d9e79'
151
- remote = "username"
152
- repository = "git@somehost.com:project.git"
153
-
154
- @config[:repository] = repository
155
- @config[:remote] = remote
156
-
157
- assert_equal "cd #{dest} && git config remote.#{remote}.url #{repository} && git config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/* && git fetch -q #{remote} && git fetch --tags -q username && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest)
158
- end
159
-
160
- def test_shallow_clone
161
- @config[:repository] = "git@somehost.com:project.git"
162
- @config[:git_shallow_clone] = 1
163
- @config[:branch] = nil
164
- dest = "/var/www"
165
- rev = 'c2d9e79'
166
- assert_equal "git clone -q --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
167
- end
168
-
169
- def test_shallow_clone_with_branch
170
- @config[:repository] = "git@somehost.com:project.git"
171
- @config[:git_shallow_clone] = 1
172
- @config[:branch] = 'foobar'
173
- dest = "/var/www"
174
- rev = 'c2d9e79'
175
- assert_equal "git clone -q -b foobar --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
176
- end
177
-
178
- def test_remote_clone
179
- @config[:repository] = "git@somehost.com:project.git"
180
- @config[:remote] = "username"
181
- dest = "/var/www"
182
- rev = 'c2d9e79'
183
- assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
184
- end
185
-
186
- def test_remote_clone_with_submodules
187
- @config[:repository] = "git@somehost.com:project.git"
188
- @config[:remote] = "username"
189
- @config[:git_enable_submodules] = true
190
- dest = "/var/www"
191
- rev = 'c2d9e79'
192
- assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && git submodule -q update --init $GIT_RECURSIVE", @source.checkout(rev, dest)
193
- end
194
-
195
- # Tests from base_test.rb, makin' sure we didn't break anything up there!
196
- def test_command_should_default_to_default_command
197
- assert_equal "git", @source.command
198
- @source.local { assert_equal "git", @source.command }
199
- end
200
-
201
- def test_command_should_use_scm_command_if_available
202
- @config[:scm_command] = "/opt/local/bin/git"
203
- assert_equal "/opt/local/bin/git", @source.command
204
- end
205
-
206
- def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
207
- @config[:scm_command] = "/opt/local/bin/git"
208
- @source.local { assert_equal "/opt/local/bin/git", @source.command }
209
- end
210
-
211
- def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
212
- @config[:scm_command] = "/opt/local/bin/git"
213
- @config[:local_scm_command] = "/usr/local/bin/git"
214
- assert_equal "/opt/local/bin/git", @source.command
215
- @source.local { assert_equal "/usr/local/bin/git", @source.command }
216
- end
217
-
218
- def test_command_should_use_default_if_scm_command_is_default
219
- @config[:scm_command] = :default
220
- assert_equal "git", @source.command
221
- end
222
-
223
- def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
224
- @config[:scm_command] = "/foo/bar/git"
225
- @config[:local_scm_command] = :default
226
- @source.local { assert_equal "git", @source.command }
227
- end
228
-
229
- def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
230
- @config[:scm_command] = "/foo/bar/git"
231
- @config[:local_scm_command] = :default
232
- assert_equal "git", @source.local.command
233
- assert_equal "/foo/bar/git", @source.command
234
- end
235
-
236
- def test_sends_password_if_set
237
- require 'capistrano/logger'
238
- text = "password:"
239
- @config[:scm_password] = "opensesame"
240
- assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
241
- end
242
-
243
- def test_prompt_password
244
- require 'capistrano/logger'
245
- require 'capistrano/cli'
246
- Capistrano::CLI.stubs(:password_prompt).returns("opensesame")
247
-
248
- text = 'password:'
249
- assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
250
- end
251
-
252
- def test_sends_passphrase_if_set
253
- require 'capistrano/logger'
254
- text = "passphrase:"
255
- @config[:scm_passphrase] = "opensesame"
256
- assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
257
- end
258
-
259
- def test_prompt_passphrase
260
- require 'capistrano/logger'
261
- require 'capistrano/cli'
262
- Capistrano::CLI.stubs(:password_prompt).returns("opensesame")
263
-
264
- text = 'passphrase:'
265
- assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
266
- end
267
-
268
- private
269
-
270
- def mock_state
271
- { :channel => { :host => "abc" } }
272
- end
273
- end
274
-