capistrano 2.8.0 → 3.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/.docker/Dockerfile +7 -0
  3. data/.docker/ssh_key_rsa +49 -0
  4. data/.docker/ssh_key_rsa.pub +1 -0
  5. data/.docker/ubuntu_setup.sh +23 -0
  6. data/.github/issue_template.md +19 -0
  7. data/.github/pull_request_template.md +22 -0
  8. data/.github/release-drafter.yml +25 -0
  9. data/.github/workflows/ci.yml +80 -0
  10. data/.github/workflows/release-drafter.yml +18 -0
  11. data/.gitignore +23 -8
  12. data/.rubocop.yml +62 -0
  13. data/CHANGELOG.md +1 -0
  14. data/CONTRIBUTING.md +63 -0
  15. data/DEVELOPMENT.md +112 -0
  16. data/Gemfile +42 -9
  17. data/LICENSE.txt +21 -0
  18. data/README.md +221 -0
  19. data/RELEASING.md +17 -0
  20. data/Rakefile +17 -8
  21. data/UPGRADING-3.7.md +86 -0
  22. data/bin/cap +2 -3
  23. data/bin/capify +7 -89
  24. data/capistrano.gemspec +29 -43
  25. data/docker-compose.yml +8 -0
  26. data/features/configuration.feature +28 -0
  27. data/features/deploy.feature +92 -0
  28. data/features/deploy_failure.feature +17 -0
  29. data/features/doctor.feature +11 -0
  30. data/features/installation.feature +21 -0
  31. data/features/sshconnect.feature +11 -0
  32. data/features/stage_failure.feature +9 -0
  33. data/features/step_definitions/assertions.rb +162 -0
  34. data/features/step_definitions/cap_commands.rb +21 -0
  35. data/features/step_definitions/setup.rb +91 -0
  36. data/features/subdirectory.feature +9 -0
  37. data/features/support/docker_gateway.rb +53 -0
  38. data/features/support/env.rb +1 -0
  39. data/features/support/remote_command_helpers.rb +29 -0
  40. data/features/support/remote_ssh_helpers.rb +33 -0
  41. data/lib/Capfile +3 -0
  42. data/lib/capistrano/all.rb +17 -0
  43. data/lib/capistrano/application.rb +153 -0
  44. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  45. data/lib/capistrano/configuration/filter.rb +26 -0
  46. data/lib/capistrano/configuration/host_filter.rb +29 -0
  47. data/lib/capistrano/configuration/null_filter.rb +9 -0
  48. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  49. data/lib/capistrano/configuration/question.rb +76 -0
  50. data/lib/capistrano/configuration/role_filter.rb +29 -0
  51. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  52. data/lib/capistrano/configuration/server.rb +137 -0
  53. data/lib/capistrano/configuration/servers.rb +56 -96
  54. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  55. data/lib/capistrano/configuration/variables.rb +79 -94
  56. data/lib/capistrano/configuration.rb +178 -33
  57. data/lib/capistrano/console.rb +1 -0
  58. data/lib/capistrano/defaults.rb +36 -0
  59. data/lib/capistrano/deploy.rb +3 -0
  60. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  61. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  62. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  63. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  64. data/lib/capistrano/doctor/variables_doctor.rb +74 -0
  65. data/lib/capistrano/doctor.rb +6 -0
  66. data/lib/capistrano/dotfile.rb +2 -0
  67. data/lib/capistrano/dsl/env.rb +43 -0
  68. data/lib/capistrano/dsl/paths.rb +89 -0
  69. data/lib/capistrano/dsl/stages.rb +31 -0
  70. data/lib/capistrano/dsl/task_enhancements.rb +61 -0
  71. data/lib/capistrano/dsl.rb +95 -0
  72. data/lib/capistrano/framework.rb +2 -0
  73. data/lib/capistrano/i18n.rb +46 -0
  74. data/lib/capistrano/immutable_task.rb +30 -0
  75. data/lib/capistrano/install.rb +1 -0
  76. data/lib/capistrano/plugin.rb +95 -0
  77. data/lib/capistrano/proc_helpers.rb +13 -0
  78. data/lib/capistrano/scm/git.rb +105 -0
  79. data/lib/capistrano/scm/hg.rb +55 -0
  80. data/lib/capistrano/scm/plugin.rb +13 -0
  81. data/lib/capistrano/scm/svn.rb +56 -0
  82. data/lib/capistrano/scm/tasks/git.rake +84 -0
  83. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  84. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  85. data/lib/capistrano/scm.rb +115 -0
  86. data/lib/capistrano/setup.rb +36 -0
  87. data/lib/capistrano/tasks/console.rake +25 -0
  88. data/lib/capistrano/tasks/deploy.rake +280 -0
  89. data/lib/capistrano/tasks/doctor.rake +24 -0
  90. data/lib/capistrano/tasks/framework.rake +67 -0
  91. data/lib/capistrano/tasks/install.rake +41 -0
  92. data/lib/capistrano/templates/Capfile +38 -0
  93. data/lib/capistrano/templates/deploy.rb.erb +39 -0
  94. data/lib/capistrano/templates/stage.rb.erb +61 -0
  95. data/lib/capistrano/upload_task.rb +9 -0
  96. data/lib/capistrano/version.rb +1 -14
  97. data/lib/capistrano/version_validator.rb +32 -0
  98. data/lib/capistrano.rb +0 -3
  99. data/spec/integration/dsl_spec.rb +632 -0
  100. data/spec/integration_spec_helper.rb +5 -0
  101. data/spec/lib/capistrano/application_spec.rb +60 -0
  102. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  103. data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
  104. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  105. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  106. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  107. data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
  108. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  109. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
  110. data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
  111. data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
  112. data/spec/lib/capistrano/configuration_spec.rb +357 -0
  113. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  114. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  115. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  116. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  117. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  118. data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
  119. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
  120. data/spec/lib/capistrano/dsl_spec.rb +125 -0
  121. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  122. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  123. data/spec/lib/capistrano/scm/git_spec.rb +194 -0
  124. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  125. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  126. data/spec/lib/capistrano/scm_spec.rb +103 -0
  127. data/spec/lib/capistrano/upload_task_spec.rb +19 -0
  128. data/spec/lib/capistrano/version_validator_spec.rb +118 -0
  129. data/spec/lib/capistrano_spec.rb +7 -0
  130. data/spec/spec_helper.rb +29 -0
  131. data/spec/support/matchers.rb +5 -0
  132. data/spec/support/tasks/database.rake +11 -0
  133. data/spec/support/tasks/fail.rake +8 -0
  134. data/spec/support/tasks/failed.rake +5 -0
  135. data/spec/support/tasks/plugin.rake +6 -0
  136. data/spec/support/tasks/root.rake +11 -0
  137. data/spec/support/test_app.rb +205 -0
  138. metadata +234 -208
  139. data/.rvmrc +0 -1
  140. data/CHANGELOG +0 -954
  141. data/README.mdown +0 -76
  142. data/lib/capistrano/callback.rb +0 -45
  143. data/lib/capistrano/cli/execute.rb +0 -85
  144. data/lib/capistrano/cli/help.rb +0 -125
  145. data/lib/capistrano/cli/help.txt +0 -81
  146. data/lib/capistrano/cli/options.rb +0 -243
  147. data/lib/capistrano/cli/ui.rb +0 -40
  148. data/lib/capistrano/cli.rb +0 -47
  149. data/lib/capistrano/command.rb +0 -286
  150. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
  151. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  152. data/lib/capistrano/configuration/actions/invocation.rb +0 -298
  153. data/lib/capistrano/configuration/callbacks.rb +0 -148
  154. data/lib/capistrano/configuration/connections.rb +0 -230
  155. data/lib/capistrano/configuration/execution.rb +0 -143
  156. data/lib/capistrano/configuration/loading.rb +0 -197
  157. data/lib/capistrano/configuration/namespaces.rb +0 -197
  158. data/lib/capistrano/configuration/roles.rb +0 -73
  159. data/lib/capistrano/errors.rb +0 -19
  160. data/lib/capistrano/ext/string.rb +0 -5
  161. data/lib/capistrano/extensions.rb +0 -57
  162. data/lib/capistrano/logger.rb +0 -59
  163. data/lib/capistrano/processable.rb +0 -53
  164. data/lib/capistrano/recipes/compat.rb +0 -32
  165. data/lib/capistrano/recipes/deploy/assets.rb +0 -57
  166. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  167. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
  168. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
  169. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  170. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
  171. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  172. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
  173. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
  174. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
  175. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
  176. data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
  177. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
  178. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
  179. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  180. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
  181. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  182. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
  183. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  184. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  185. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
  186. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  187. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  188. data/lib/capistrano/recipes/deploy.rb +0 -568
  189. data/lib/capistrano/recipes/standard.rb +0 -37
  190. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  191. data/lib/capistrano/role.rb +0 -102
  192. data/lib/capistrano/server_definition.rb +0 -56
  193. data/lib/capistrano/shell.rb +0 -260
  194. data/lib/capistrano/ssh.rb +0 -101
  195. data/lib/capistrano/task_definition.rb +0 -75
  196. data/lib/capistrano/transfer.rb +0 -216
  197. data/rvmrc.sample +0 -1
  198. data/test/cli/execute_test.rb +0 -132
  199. data/test/cli/help_test.rb +0 -165
  200. data/test/cli/options_test.rb +0 -329
  201. data/test/cli/ui_test.rb +0 -28
  202. data/test/cli_test.rb +0 -17
  203. data/test/command_test.rb +0 -289
  204. data/test/configuration/actions/file_transfer_test.rb +0 -61
  205. data/test/configuration/actions/inspect_test.rb +0 -65
  206. data/test/configuration/actions/invocation_test.rb +0 -247
  207. data/test/configuration/callbacks_test.rb +0 -220
  208. data/test/configuration/connections_test.rb +0 -420
  209. data/test/configuration/execution_test.rb +0 -175
  210. data/test/configuration/loading_test.rb +0 -132
  211. data/test/configuration/namespace_dsl_test.rb +0 -311
  212. data/test/configuration/roles_test.rb +0 -144
  213. data/test/configuration/servers_test.rb +0 -183
  214. data/test/configuration/variables_test.rb +0 -190
  215. data/test/configuration_test.rb +0 -88
  216. data/test/deploy/local_dependency_test.rb +0 -76
  217. data/test/deploy/remote_dependency_test.rb +0 -135
  218. data/test/deploy/scm/accurev_test.rb +0 -23
  219. data/test/deploy/scm/base_test.rb +0 -55
  220. data/test/deploy/scm/bzr_test.rb +0 -51
  221. data/test/deploy/scm/darcs_test.rb +0 -37
  222. data/test/deploy/scm/git_test.rb +0 -184
  223. data/test/deploy/scm/mercurial_test.rb +0 -134
  224. data/test/deploy/scm/none_test.rb +0 -35
  225. data/test/deploy/scm/subversion_test.rb +0 -32
  226. data/test/deploy/strategy/copy_test.rb +0 -321
  227. data/test/extensions_test.rb +0 -69
  228. data/test/fixtures/cli_integration.rb +0 -5
  229. data/test/fixtures/config.rb +0 -5
  230. data/test/fixtures/custom.rb +0 -3
  231. data/test/logger_test.rb +0 -123
  232. data/test/recipes_test.rb +0 -25
  233. data/test/role_test.rb +0 -11
  234. data/test/server_definition_test.rb +0 -121
  235. data/test/shell_test.rb +0 -90
  236. data/test/ssh_test.rb +0 -113
  237. data/test/task_definition_test.rb +0 -116
  238. data/test/transfer_test.rb +0 -160
  239. data/test/utils.rb +0 -37
@@ -1,282 +0,0 @@
1
- require 'capistrano/recipes/deploy/scm/base'
2
-
3
- module Capistrano
4
- module Deploy
5
- module SCM
6
-
7
- # An SCM module for using Git as your source control tool with Capistrano
8
- # 2.0. If you are using Capistrano 1.x, use this plugin instead:
9
- #
10
- # http://scie.nti.st/2007/3/16/capistrano-with-git-shared-repository
11
- #
12
- # Assumes you are using a shared Git repository.
13
- #
14
- # Parts of this plugin borrowed from Scott Chacon's version, which I
15
- # found on the Capistrano mailing list but failed to be able to get
16
- # working.
17
- #
18
- # FEATURES:
19
- #
20
- # * Very simple, only requiring 2 lines in your deploy.rb.
21
- # * Can deploy different branches, tags, or any SHA1 easily.
22
- # * Supports prompting for password / passphrase upon checkout.
23
- # (I am amazed at how some plugins don't do this)
24
- # * Supports :scm_command, :scm_password, :scm_passphrase Capistrano
25
- # directives.
26
- #
27
- # CONFIGURATION
28
- # -------------
29
- #
30
- # Use this plugin by adding the following line in your config/deploy.rb:
31
- #
32
- # set :scm, :git
33
- #
34
- # Set <tt>:repository</tt> to the path of your Git repo:
35
- #
36
- # set :repository, "someuser@somehost:/home/myproject"
37
- #
38
- # The above two options are required to be set, the ones below are
39
- # optional.
40
- #
41
- # You may set <tt>:branch</tt>, which is the reference to the branch, tag,
42
- # or any SHA1 you are deploying, for example:
43
- #
44
- # set :branch, "master"
45
- #
46
- # Otherwise, HEAD is assumed. I strongly suggest you set this. HEAD is
47
- # not always the best assumption.
48
- #
49
- # You may also set <tt>:remote</tt>, which will be used as a name for remote
50
- # tracking of repositories. This option is intended for use with the
51
- # <tt>:remote_cache</tt> strategy in a distributed git environment.
52
- #
53
- # For example in the projects <tt>config/deploy.rb</tt>:
54
- #
55
- # set :repository, "#{scm_user}@somehost:~/projects/project.git"
56
- # set :remote, "#{scm_user}"
57
- #
58
- # Then each person with deploy priveledges can add the following to their
59
- # local <tt>~/.caprc</tt> file:
60
- #
61
- # set :scm_user, 'someuser'
62
- #
63
- # Now any time a person deploys the project, their repository will be
64
- # setup as a remote git repository within the cached repository.
65
- #
66
- # The <tt>:scm_command</tt> configuration variable, if specified, will
67
- # be used as the full path to the git executable on the *remote* machine:
68
- #
69
- # set :scm_command, "/opt/local/bin/git"
70
- #
71
- # For compatibility with deploy scripts that may have used the 1.x
72
- # version of this plugin before upgrading, <tt>:git</tt> is still
73
- # recognized as an alias for :scm_command.
74
- #
75
- # Set <tt>:scm_password</tt> to the password needed to clone your repo
76
- # if you don't have password-less (public key) entry:
77
- #
78
- # set :scm_password, "my_secret'
79
- #
80
- # Otherwise, you will be prompted for a password.
81
- #
82
- # <tt>:scm_passphrase</tt> is also supported.
83
- #
84
- # The remote cache strategy is also supported.
85
- #
86
- # set :repository_cache, "git_master"
87
- # set :deploy_via, :remote_cache
88
- #
89
- # For faster clone, you can also use shallow cloning. This will set the
90
- # '--depth' flag using the depth specified. This *cannot* be used
91
- # together with the :remote_cache strategy
92
- #
93
- # set :git_shallow_clone, 1
94
- #
95
- # For those that don't like to leave your entire repository on
96
- # your production server you can:
97
- #
98
- # set :deploy_via, :export
99
- #
100
- # To deploy from a local repository:
101
- #
102
- # set :repository, "file://."
103
- # set :deploy_via, :copy
104
- #
105
- # AUTHORS
106
- # -------
107
- #
108
- # Garry Dolley http://scie.nti.st
109
- # Contributions by Geoffrey Grosenbach http://topfunky.com
110
- # Scott Chacon http://jointheconversation.org
111
- # Alex Arnell http://twologic.com
112
- # and Phillip Goldenburg
113
-
114
- class Git < Base
115
- # Sets the default command name for this SCM on your *local* machine.
116
- # Users may override this by setting the :scm_command variable.
117
- default_command "git"
118
-
119
- # When referencing "head", use the branch we want to deploy or, by
120
- # default, Git's reference of HEAD (the latest changeset in the default
121
- # branch, usually called "master").
122
- def head
123
- variable(:branch) || 'HEAD'
124
- end
125
-
126
- def origin
127
- variable(:remote) || 'origin'
128
- end
129
-
130
- # Performs a clone on the remote machine, then checkout on the branch
131
- # you want to deploy.
132
- def checkout(revision, destination)
133
- git = command
134
- remote = origin
135
-
136
- args = []
137
- args << "-o #{remote}" unless remote == 'origin'
138
- if depth = variable(:git_shallow_clone)
139
- args << "--depth #{depth}"
140
- end
141
-
142
- execute = []
143
- execute << "#{git} clone #{verbose} #{args.join(' ')} #{variable(:repository)} #{destination}"
144
-
145
- # checkout into a local branch rather than a detached HEAD
146
- execute << "cd #{destination} && #{git} checkout #{verbose} -b deploy #{revision}"
147
-
148
- if variable(:git_enable_submodules)
149
- execute << "#{git} submodule #{verbose} init"
150
- execute << "#{git} submodule #{verbose} sync"
151
- if false == variable(:git_submodules_recursive)
152
- execute << "#{git} submodule #{verbose} update --init"
153
- else
154
- execute << "#{git} submodule #{verbose} update --init --recursive"
155
- end
156
- end
157
-
158
- execute.join(" && ").compact
159
- end
160
-
161
- # An expensive export. Performs a checkout as above, then
162
- # removes the repo.
163
- def export(revision, destination)
164
- checkout(revision, destination) << " && rm -Rf #{destination}/.git"
165
- end
166
-
167
- # Merges the changes to 'head' since the last fetch, for remote_cache
168
- # deployment strategy
169
- def sync(revision, destination)
170
- git = command
171
- remote = origin
172
-
173
- execute = []
174
- execute << "cd #{destination}"
175
-
176
- # Use git-config to setup a remote tracking branches. Could use
177
- # git-remote but it complains when a remote of the same name already
178
- # exists, git-config will just silenty overwrite the setting every
179
- # time. This could cause wierd-ness in the remote cache if the url
180
- # changes between calls, but as long as the repositories are all
181
- # based from each other it should still work fine.
182
- if remote != 'origin'
183
- execute << "#{git} config remote.#{remote}.url #{variable(:repository)}"
184
- execute << "#{git} config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/*"
185
- end
186
-
187
- # since we're in a local branch already, just reset to specified revision rather than merge
188
- execute << "#{git} fetch #{verbose} #{remote} && #{git} fetch --tags #{verbose} #{remote} && #{git} reset #{verbose} --hard #{revision}"
189
-
190
- if variable(:git_enable_submodules)
191
- execute << "#{git} submodule #{verbose} init"
192
- execute << "for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done"
193
- execute << "#{git} submodule #{verbose} sync"
194
- if false == variable(:git_submodules_recursive)
195
- execute << "#{git} submodule #{verbose} update --init"
196
- else
197
- execute << "#{git} submodule #{verbose} update --init --recursive"
198
- end
199
- end
200
-
201
- # Make sure there's nothing else lying around in the repository (for
202
- # example, a submodule that has subsequently been removed).
203
- execute << "#{git} clean #{verbose} -d -x -f"
204
-
205
- execute.join(" && ")
206
- end
207
-
208
- # Returns a string of diffs between two revisions
209
- def diff(from, to=nil)
210
- return scm :diff, from unless to
211
- scm :diff, "#{from}..#{to}"
212
- end
213
-
214
- # Returns a log of changes between the two revisions (inclusive).
215
- def log(from, to=nil)
216
- scm :log, "#{from}..#{to}"
217
- end
218
-
219
- # Getting the actual commit id, in case we were passed a tag
220
- # or partial sha or something - it will return the sha if you pass a sha, too
221
- def query_revision(revision)
222
- raise ArgumentError, "Deploying remote branches is no longer supported. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{revision.gsub('origin/', '')}' rather than '#{revision}')." if revision =~ /^origin\//
223
- return revision if revision =~ /^[0-9a-f]{40}$/
224
- command = scm('ls-remote', repository, revision)
225
- result = yield(command)
226
- revdata = result.split(/[\t\n]/)
227
- newrev = nil
228
- revdata.each_slice(2) do |refs|
229
- rev, ref = *refs
230
- if ref.sub(/refs\/.*?\//, '').strip == revision.to_s
231
- newrev = rev
232
- break
233
- end
234
- end
235
- raise "Unable to resolve revision for '#{revision}' on repository '#{repository}'." unless newrev =~ /^[0-9a-f]{40}$/
236
- return newrev
237
- end
238
-
239
- def command
240
- # For backwards compatibility with 1.x version of this module
241
- variable(:git) || super
242
- end
243
-
244
- # Determines what the response should be for a particular bit of text
245
- # from the SCM. Password prompts, connection requests, passphrases,
246
- # etc. are handled here.
247
- def handle_data(state, stream, text)
248
- host = state[:channel][:host]
249
- logger.info "[#{host} :: #{stream}] #{text}"
250
- case text
251
- when /\bpassword.*:/i
252
- # git is prompting for a password
253
- unless pass = variable(:scm_password)
254
- pass = Capistrano::CLI.password_prompt
255
- end
256
- "#{pass}\n"
257
- when %r{\(yes/no\)}
258
- # git is asking whether or not to connect
259
- "yes\n"
260
- when /passphrase/i
261
- # git is asking for the passphrase for the user's key
262
- unless pass = variable(:scm_passphrase)
263
- pass = Capistrano::CLI.password_prompt
264
- end
265
- "#{pass}\n"
266
- when /accept \(t\)emporarily/
267
- # git is asking whether to accept the certificate
268
- "t\n"
269
- end
270
- end
271
-
272
- private
273
-
274
- # If verbose output is requested, return nil, otherwise return the
275
- # command-line switch for "quiet" ("-q").
276
- def verbose
277
- variable(:scm_verbose, true) ? "-q" : nil
278
- end
279
- end
280
- end
281
- end
282
- end
@@ -1,137 +0,0 @@
1
- # Copyright 2007 Matthew Elder <sseses@gmail.com>
2
- # based on work by Tobias Luetke
3
-
4
- require 'capistrano/recipes/deploy/scm/base'
5
-
6
- module Capistrano
7
- module Deploy
8
- module SCM
9
-
10
- # Implements the Capistrano SCM interface for the Mercurial revision
11
- # control system (http://www.selenic.com/mercurial/).
12
- # Latest updates at http://tackletechnology.org/oss/cap2-mercurial
13
- class Mercurial < Base
14
- # Sets the default command name for this SCM. Users may override this
15
- # by setting the :scm_command variable.
16
- default_command "hg"
17
-
18
- # For mercurial HEAD == tip except that it bases this assumption on what
19
- # tip is in the current repository (so push before you deploy)
20
- def head
21
- variable(:branch) || "tip"
22
- end
23
-
24
- # Clone the repository and update to the specified changeset.
25
- def checkout(changeset, destination)
26
- clone(destination) + " && " + update(changeset, destination)
27
- end
28
-
29
- # Pull from the repository and update to the specified changeset.
30
- def sync(changeset, destination)
31
- pull(destination) + " && " + update(changeset, destination)
32
- end
33
-
34
- # One day we will have hg archive, although i think its not needed
35
- def export(revision, destination)
36
- raise NotImplementedError, "`diff' is not implemented by #{self.class.name}" +
37
- "use checkout strategy"
38
- end
39
-
40
- # Compute the difference between the two changesets +from+ and +to+
41
- # as a unified diff.
42
- def diff(from, to=nil)
43
- scm :diff,
44
- "--rev #{from}",
45
- (to ? "--rev #{to}" : nil)
46
- end
47
-
48
- # Return a log of all changes between the two specified changesets,
49
- # +from+ and +to+, inclusive or the log for +from+ if +to+ is omitted.
50
- def log(from, to=nil)
51
- scm :log,
52
- verbose,
53
- "--rev #{from}" +
54
- (to ? ":#{to}" : "")
55
- end
56
-
57
- # Translates a tag to a changeset if needed or just returns changeset.
58
- def query_revision(changeset)
59
- cmd = scm :log,
60
- verbose,
61
- "-r #{changeset}",
62
- "--template '{node|short}'"
63
- yield cmd
64
- end
65
-
66
- # Determine response for SCM prompts
67
- # user/pass can come from ssh and http distribution methods
68
- # yes/no is for when ssh asks you about fingerprints
69
- def handle_data(state, stream, text)
70
- host = state[:channel][:host]
71
- logger.info "[#{host} :: #{stream}] #{text}"
72
- case text
73
- when /^user:/mi
74
- # support :scm_user for backwards compatibility of this module
75
- if user = variable(:scm_username) || variable(:scm_user)
76
- "#{user}\n"
77
- else
78
- raise "No variable :scm_username specified and Mercurial asked!\n" +
79
- "Prompt was: #{text}"
80
- end
81
- when /\bpassword:/mi
82
- unless pass = scm_password_or_prompt
83
- # fall back on old behavior of erroring out with msg
84
- raise "No variable :scm_password specified and Mercurial asked!\n" +
85
- "Prompt was: #{text}"
86
- end
87
- "#{pass}\n"
88
- when /yes\/no/i
89
- "yes\n"
90
- end
91
- end
92
-
93
- private
94
-
95
- # Fine grained mercurial commands
96
- def clone(destination)
97
- scm :clone,
98
- verbose,
99
- "--noupdate", # do not update to tip when cloning is done
100
- repository, # clone which repository?
101
- destination # and put the clone where?
102
- end
103
-
104
- def pull(destination)
105
- scm :pull,
106
- verbose,
107
- "--repository #{destination}", # pull changes into what?
108
- repository # and pull the changes from?
109
- end
110
-
111
- def update(changeset, destination)
112
- scm :update,
113
- verbose,
114
- "--repository #{destination}", # update what?
115
- "--clean", # ignore untracked changes
116
- changeset # update to this changeset
117
- end
118
-
119
- # verbosity configuration grokking :)
120
- def verbose
121
- case variable(:scm_verbose)
122
- when nil then nil
123
- when false then "--quiet"
124
- else "--verbose"
125
- end
126
- end
127
-
128
- # honor Cap 2.1+'s :scm_prefer_prompt if present
129
- def scm_password_or_prompt
130
- @scm_password_or_prompt ||= variable(:scm_password) ||
131
- (Capistrano::CLI.password_prompt("hg password: ") if variable(:scm_prefer_prompt))
132
- end
133
-
134
- end
135
- end
136
- end
137
- end
@@ -1,44 +0,0 @@
1
- require 'capistrano/recipes/deploy/scm/base'
2
-
3
- module Capistrano
4
- module Deploy
5
- module SCM
6
-
7
- # A trivial SCM wrapper for representing the current working directory
8
- # as a repository. Obviously, not all operations are available for this
9
- # SCM, but it works sufficiently for use with the "copy" deployment
10
- # strategy.
11
- #
12
- # Use of this module is _not_ recommended; in general, it is good
13
- # practice to use some kind of source code management even for anything
14
- # you are wanting to deploy. However, this module is provided in
15
- # acknowledgement of the cases where trivial deployment of your current
16
- # working directory is desired.
17
- #
18
- # set :repository, "."
19
- # set :scm, :none
20
- # set :deploy_via, :copy
21
- class None < Base
22
- # No versioning, thus, no head. Returns the empty string.
23
- def head
24
- ""
25
- end
26
-
27
- # Simply does a copy from the :repository directory to the
28
- # :destination directory.
29
- def checkout(revision, destination)
30
- !Capistrano::Deploy::LocalDependency.on_windows? ? "cp -R #{repository} #{destination}" : "xcopy #{repository} \"#{destination}\" /S/I/Y/Q/E"
31
- end
32
-
33
- alias_method :export, :checkout
34
-
35
- # No versioning, so this just returns the argument, with no
36
- # modification.
37
- def query_revision(revision)
38
- revision
39
- end
40
- end
41
-
42
- end
43
- end
44
- end
@@ -1,138 +0,0 @@
1
- require 'capistrano/recipes/deploy/scm/base'
2
-
3
- # Notes:
4
- # no global verbose flag for scm_verbose
5
- # sync, checkout and export are just sync in p4
6
- #
7
- module Capistrano
8
- module Deploy
9
- module SCM
10
-
11
- # Implements the Capistrano SCM interface for the Perforce revision
12
- # control system (http://www.perforce.com).
13
- class Perforce < Base
14
- # Sets the default command name for this SCM. Users may override this
15
- # by setting the :scm_command variable.
16
- default_command "p4"
17
-
18
- # Perforce understands '#head' to refer to the latest revision in the
19
- # depot.
20
- def head
21
- 'head'
22
- end
23
-
24
- # Returns the command that will sync the given revision to the given
25
- # destination directory. The perforce client has a fixed destination so
26
- # the files must be copied from there to their intended resting place.
27
- def checkout(revision, destination)
28
- p4_sync(revision, destination, p4sync_flags)
29
- end
30
-
31
- # Returns the command that will sync the given revision to the given
32
- # destination directory. The perforce client has a fixed destination so
33
- # the files must be copied from there to their intended resting place.
34
- def sync(revision, destination)
35
- p4_sync(revision, destination, p4sync_flags)
36
- end
37
-
38
- # Returns the command that will sync the given revision to the given
39
- # destination directory. The perforce client has a fixed destination so
40
- # the files must be copied from there to their intended resting place.
41
- def export(revision, destination)
42
- p4_sync(revision, destination, p4sync_flags)
43
- end
44
-
45
- # Returns the command that will do an "p4 diff2" for the two revisions.
46
- def diff(from, to=head)
47
- scm authentication, :diff2, "-u -db", "//#{p4client}/...#{rev_no(from)}", "//#{p4client}/...#{rev_no(to)}"
48
- end
49
-
50
- # Returns a "p4 changes" command for the two revisions.
51
- def log(from=1, to=head)
52
- scm authentication, :changes, "-s submitted", "//#{p4client}/...#{rev_no(from)},#{rev_no(to)}"
53
- end
54
-
55
- def query_revision(revision)
56
- return revision if revision.to_s =~ /^\d+$/
57
- command = scm(authentication, :changes, "-s submitted", "-m 1", "//#{p4client}/...#{rev_no(revision)}")
58
- yield(command)[/Change (\d+) on/, 1]
59
- end
60
-
61
- # Increments the given revision number and returns it.
62
- def next_revision(revision)
63
- revision.to_i + 1
64
- end
65
-
66
- # Determines what the response should be for a particular bit of text
67
- # from the SCM. Password prompts, connection requests, passphrases,
68
- # etc. are handled here.
69
- def handle_data(state, stream, text)
70
- case text
71
- when /\(P4PASSWD\) invalid or unset\./i
72
- raise Capistrano::Error, "scm_password (or p4passwd) is incorrect or unset"
73
- when /Can.t create a new user.*/i
74
- raise Capistrano::Error, "scm_username (or p4user) is incorrect or unset"
75
- when /Perforce client error\:/i
76
- raise Capistrano::Error, "p4port is incorrect or unset"
77
- when /Client \'[\w\-\_\.]+\' unknown.*/i
78
- raise Capistrano::Error, "p4client is incorrect or unset"
79
- end
80
- end
81
-
82
- private
83
-
84
- # Builds the set of authentication switches that perforce understands.
85
- def authentication
86
- [ p4port && "-p #{p4port}",
87
- p4user && "-u #{p4user}",
88
- p4passwd && "-P #{p4passwd}",
89
- p4client && "-c #{p4client}" ].compact.join(" ")
90
- end
91
-
92
- # Returns the command that will sync the given revision to the given
93
- # destination directory with specific options. The perforce client has
94
- # a fixed destination so the files must be copied from there to their
95
- # intended resting place.
96
- def p4_sync(revision, destination, options="")
97
- scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}"
98
- end
99
-
100
- def p4client
101
- variable(:p4client)
102
- end
103
-
104
- def p4port
105
- variable(:p4port)
106
- end
107
-
108
- def p4user
109
- variable(:p4user) || variable(:scm_username)
110
- end
111
-
112
- def p4passwd
113
- variable(:p4passwd) || variable(:scm_password)
114
- end
115
-
116
- def p4sync_flags
117
- variable(:p4sync_flags) || "-f"
118
- end
119
-
120
- def p4client_root
121
- variable(:p4client_root) || "`#{command} #{authentication} client -o | grep ^Root | cut -f2`"
122
- end
123
-
124
- def rev_no(revision)
125
- case revision.to_s
126
- when "head"
127
- "#head"
128
- when /^\d+/
129
- "@#{revision}"
130
- else
131
- revision
132
- end
133
- end
134
- end
135
-
136
- end
137
- end
138
- end