capistrano 2.1.0 → 3.0.0

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.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +89 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +674 -0
  7. data/README.md +226 -0
  8. data/Rakefile +5 -0
  9. data/bin/cap +2 -3
  10. data/bin/capify +7 -77
  11. data/capistrano-public_cert.pem +22 -0
  12. data/capistrano.gemspec +35 -0
  13. data/features/deploy.feature +52 -0
  14. data/features/installation.feature +16 -0
  15. data/features/remote_file_task.feature +14 -0
  16. data/features/step_definitions/assertions.rb +90 -0
  17. data/features/step_definitions/cap_commands.rb +8 -0
  18. data/features/step_definitions/setup.rb +25 -0
  19. data/features/support/env.rb +12 -0
  20. data/features/support/remote_command_helpers.rb +20 -0
  21. data/lib/Capfile +3 -0
  22. data/lib/capistrano/all.rb +16 -0
  23. data/lib/capistrano/application.rb +60 -0
  24. data/lib/capistrano/configuration/question.rb +42 -0
  25. data/lib/capistrano/configuration/server.rb +133 -0
  26. data/lib/capistrano/configuration/servers/role_filter.rb +86 -0
  27. data/lib/capistrano/configuration/servers.rb +53 -58
  28. data/lib/capistrano/configuration.rb +84 -30
  29. data/lib/capistrano/console.rb +1 -0
  30. data/lib/capistrano/defaults.rb +13 -0
  31. data/lib/capistrano/deploy.rb +3 -0
  32. data/lib/capistrano/dotfile.rb +3 -0
  33. data/lib/capistrano/dsl/env.rb +64 -0
  34. data/lib/capistrano/dsl/paths.rb +94 -0
  35. data/lib/capistrano/dsl/stages.rb +15 -0
  36. data/lib/capistrano/dsl/task_enhancements.rb +53 -0
  37. data/lib/capistrano/dsl.rb +48 -0
  38. data/lib/capistrano/git.rb +1 -0
  39. data/lib/capistrano/hg.rb +1 -0
  40. data/lib/capistrano/i18n.rb +34 -0
  41. data/lib/capistrano/install.rb +1 -0
  42. data/lib/capistrano/setup.rb +21 -0
  43. data/lib/capistrano/tasks/console.rake +21 -0
  44. data/lib/capistrano/tasks/deploy.rake +204 -0
  45. data/lib/capistrano/tasks/framework.rake +67 -0
  46. data/lib/capistrano/tasks/git.rake +62 -0
  47. data/lib/capistrano/tasks/hg.rake +39 -0
  48. data/lib/capistrano/tasks/install.rake +39 -0
  49. data/lib/capistrano/templates/Capfile +26 -0
  50. data/lib/capistrano/templates/deploy.rb.erb +40 -0
  51. data/lib/capistrano/templates/stage.rb.erb +42 -0
  52. data/lib/capistrano/version.rb +1 -20
  53. data/lib/capistrano/version_validator.rb +37 -0
  54. data/lib/capistrano.rb +0 -2
  55. data/spec/integration/dsl_spec.rb +344 -0
  56. data/spec/integration_spec_helper.rb +7 -0
  57. data/spec/lib/capistrano/application_spec.rb +61 -0
  58. data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
  59. data/spec/lib/capistrano/configuration/server_spec.rb +249 -0
  60. data/spec/lib/capistrano/configuration/servers/role_filter_spec.rb +140 -0
  61. data/spec/lib/capistrano/configuration/servers_spec.rb +184 -0
  62. data/spec/lib/capistrano/configuration_spec.rb +101 -0
  63. data/spec/lib/capistrano/dsl/env_spec.rb +10 -0
  64. data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
  65. data/spec/lib/capistrano/dsl_spec.rb +63 -0
  66. data/spec/lib/capistrano/version_validator_spec.rb +103 -0
  67. data/spec/lib/capistrano_spec.rb +8 -0
  68. data/spec/spec_helper.rb +15 -0
  69. data/spec/support/.gitignore +1 -0
  70. data/spec/support/Vagrantfile +13 -0
  71. data/spec/support/matchers.rb +5 -0
  72. data/spec/support/tasks/database.cap +11 -0
  73. data/spec/support/test_app.rb +138 -0
  74. metadata +251 -179
  75. data/CHANGELOG +0 -512
  76. data/MIT-LICENSE +0 -20
  77. data/README +0 -43
  78. data/examples/sample.rb +0 -14
  79. data/lib/capistrano/callback.rb +0 -45
  80. data/lib/capistrano/cli/execute.rb +0 -82
  81. data/lib/capistrano/cli/help.rb +0 -102
  82. data/lib/capistrano/cli/help.txt +0 -53
  83. data/lib/capistrano/cli/options.rb +0 -183
  84. data/lib/capistrano/cli/ui.rb +0 -28
  85. data/lib/capistrano/cli.rb +0 -47
  86. data/lib/capistrano/command.rb +0 -161
  87. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -35
  88. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  89. data/lib/capistrano/configuration/actions/invocation.rb +0 -134
  90. data/lib/capistrano/configuration/callbacks.rb +0 -148
  91. data/lib/capistrano/configuration/connections.rb +0 -159
  92. data/lib/capistrano/configuration/execution.rb +0 -126
  93. data/lib/capistrano/configuration/loading.rb +0 -198
  94. data/lib/capistrano/configuration/namespaces.rb +0 -196
  95. data/lib/capistrano/configuration/roles.rb +0 -51
  96. data/lib/capistrano/configuration/variables.rb +0 -127
  97. data/lib/capistrano/errors.rb +0 -15
  98. data/lib/capistrano/extensions.rb +0 -57
  99. data/lib/capistrano/gateway.rb +0 -131
  100. data/lib/capistrano/logger.rb +0 -59
  101. data/lib/capistrano/recipes/compat.rb +0 -32
  102. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  103. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -46
  104. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -96
  105. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  106. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -192
  107. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  108. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -151
  109. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -85
  110. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -191
  111. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -129
  112. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -126
  113. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -114
  114. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  115. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -64
  116. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  117. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -144
  118. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  119. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  120. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -47
  121. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  122. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  123. data/lib/capistrano/recipes/deploy.rb +0 -494
  124. data/lib/capistrano/recipes/standard.rb +0 -37
  125. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  126. data/lib/capistrano/recipes/upgrade.rb +0 -33
  127. data/lib/capistrano/server_definition.rb +0 -51
  128. data/lib/capistrano/shell.rb +0 -256
  129. data/lib/capistrano/ssh.rb +0 -109
  130. data/lib/capistrano/task_definition.rb +0 -69
  131. data/lib/capistrano/upload.rb +0 -146
  132. data/test/cli/execute_test.rb +0 -132
  133. data/test/cli/help_test.rb +0 -139
  134. data/test/cli/options_test.rb +0 -226
  135. data/test/cli/ui_test.rb +0 -28
  136. data/test/cli_test.rb +0 -17
  137. data/test/command_test.rb +0 -309
  138. data/test/configuration/actions/file_transfer_test.rb +0 -40
  139. data/test/configuration/actions/inspect_test.rb +0 -62
  140. data/test/configuration/actions/invocation_test.rb +0 -202
  141. data/test/configuration/callbacks_test.rb +0 -206
  142. data/test/configuration/connections_test.rb +0 -288
  143. data/test/configuration/execution_test.rb +0 -159
  144. data/test/configuration/loading_test.rb +0 -127
  145. data/test/configuration/namespace_dsl_test.rb +0 -297
  146. data/test/configuration/roles_test.rb +0 -47
  147. data/test/configuration/servers_test.rb +0 -90
  148. data/test/configuration/variables_test.rb +0 -180
  149. data/test/configuration_test.rb +0 -81
  150. data/test/deploy/scm/accurev_test.rb +0 -23
  151. data/test/deploy/scm/base_test.rb +0 -55
  152. data/test/deploy/scm/git_test.rb +0 -112
  153. data/test/deploy/strategy/copy_test.rb +0 -147
  154. data/test/extensions_test.rb +0 -69
  155. data/test/fixtures/cli_integration.rb +0 -5
  156. data/test/fixtures/config.rb +0 -5
  157. data/test/fixtures/custom.rb +0 -3
  158. data/test/gateway_test.rb +0 -167
  159. data/test/logger_test.rb +0 -123
  160. data/test/server_definition_test.rb +0 -108
  161. data/test/shell_test.rb +0 -64
  162. data/test/ssh_test.rb +0 -97
  163. data/test/task_definition_test.rb +0 -101
  164. data/test/upload_test.rb +0 -131
  165. data/test/utils.rb +0 -42
  166. data/test/version_test.rb +0 -24
@@ -1,191 +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
- # REQUIREMENTS
28
- # ------------
29
- #
30
- # Git is required to be installed on your remote machine(s), because a
31
- # clone and checkout is done to get the code up there. This is the way
32
- # I prefer to deploy; there is no alternative to this, so :deploy_via
33
- # is ignored.
34
- #
35
- # CONFIGURATION
36
- # -------------
37
- #
38
- # Use this plugin by adding the following line in your config/deploy.rb:
39
- #
40
- # set :scm, :git
41
- #
42
- # Set <tt>:repository</tt> to the path of your Git repo:
43
- #
44
- # set :repository, "someuser@somehost:/home/myproject"
45
- #
46
- # The above two options are required to be set, the ones below are
47
- # optional.
48
- #
49
- # You may set <tt>:branch</tt>, which is the reference to the branch, tag,
50
- # or any SHA1 you are deploying, for example:
51
- #
52
- # set :branch, "origin/master"
53
- #
54
- # Otherwise, HEAD is assumed. I strongly suggest you set this. HEAD is
55
- # not always the best assumption.
56
- #
57
- # The <tt>:scm_command</tt> configuration variable, if specified, will
58
- # be used as the full path to the git executable on the *remote* machine:
59
- #
60
- # set :scm_command, "/opt/local/bin/git"
61
- #
62
- # For compatibility with deploy scripts that may have used the 1.x
63
- # version of this plugin before upgrading, <tt>:git</tt> is still
64
- # recognized as an alias for :scm_command.
65
- #
66
- # Set <tt>:scm_password</tt> to the password needed to clone your repo
67
- # if you don't have password-less (public key) entry:
68
- #
69
- # set :scm_password, "my_secret'
70
- #
71
- # Otherwise, you will be prompted for a password.
72
- #
73
- # <tt>:scm_passphrase</tt> is also supported.
74
- #
75
- # The remote cache strategy is also supported.
76
- #
77
- # set :repository_cache, "git_master"
78
- # set :deploy_via, :remote_cache
79
- #
80
- # For faster clone, you can also use shallow cloning. This will set the
81
- # '--depth' flag using the depth specified. This *cannot* be used
82
- # together with the :remote_cache strategy
83
- #
84
- # set :git_shallow_clone, 1
85
- #
86
- # AUTHORS
87
- # -------
88
- #
89
- # Garry Dolley http://scie.nti.st
90
- # Contributions by Geoffrey Grosenbach http://topfunky.com
91
- # and Scott Chacon http://jointheconversation.org
92
-
93
- class Git < Base
94
- # Sets the default command name for this SCM on your *local* machine.
95
- # Users may override this by setting the :scm_command variable.
96
- default_command "git"
97
-
98
- # When referencing "head", use the branch we want to deploy or, by
99
- # default, Git's reference of HEAD (the latest changeset in the default
100
- # branch, usually called "master").
101
- def head
102
- configuration[:branch] || 'HEAD'
103
- end
104
-
105
- # Performs a clone on the remote machine, then checkout on the branch
106
- # you want to deploy.
107
- def checkout(revision, destination)
108
- git = command
109
-
110
- branch = head
111
-
112
- fail "No branch specified, use for example 'set :branch, \"origin/master\"' in your deploy.rb" unless branch
113
-
114
- if depth = configuration[:git_shallow_clone]
115
- execute = "#{git} clone --depth #{depth} #{configuration[:repository]} #{destination} && "
116
- else
117
- execute = "#{git} clone #{configuration[:repository]} #{destination} && "
118
- end
119
-
120
- execute += "cd #{destination} && #{git} checkout -b deploy #{branch}"
121
-
122
- execute
123
- end
124
-
125
- # Merges the changes to 'head' since the last fetch, for remote_cache
126
- # deployment strategy
127
- def sync(revision, destination)
128
- execute = "cd #{destination} && git fetch origin && "
129
-
130
- if head == 'HEAD'
131
- execute += "git merge origin/HEAD"
132
- else
133
- execute += "git merge #{head}"
134
- end
135
-
136
- execute
137
- end
138
-
139
- # Returns a string of diffs between two revisions
140
- def diff(from, to=nil)
141
- from << "..#{to}" if to
142
- scm :diff, from
143
- end
144
-
145
- # Returns a log of changes between the two revisions (inclusive).
146
- def log(from, to=nil)
147
- from << "..#{to}" if to
148
- scm :log, from
149
- end
150
-
151
- # Getting the actual commit id, in case we were passed a tag
152
- # or partial sha or something - it will return the sha if you pass a sha, too
153
- def query_revision(revision)
154
- yield(scm('rev-parse', revision)).chomp
155
- end
156
-
157
- def command
158
- # For backwards compatibility with 1.x version of this module
159
- configuration[:git] || super
160
- end
161
-
162
- # Determines what the response should be for a particular bit of text
163
- # from the SCM. Password prompts, connection requests, passphrases,
164
- # etc. are handled here.
165
- def handle_data(state, stream, text)
166
- logger.info "[#{stream}] #{text}"
167
- case text
168
- when /\bpassword.*:/i
169
- # git is prompting for a password
170
- unless pass = configuration[:scm_password]
171
- pass = Capistrano::CLI.password_prompt
172
- end
173
- "#{pass}\n"
174
- when %r{\(yes/no\)}
175
- # git is asking whether or not to connect
176
- "yes\n"
177
- when /passphrase/i
178
- # git is asking for the passphrase for the user's key
179
- unless pass = configuration[:scm_passphrase]
180
- pass = Capistrano::CLI.password_prompt
181
- end
182
- "#{pass}\n"
183
- when /accept \(t\)emporarily/
184
- # git is asking whether to accept the certificate
185
- "t\n"
186
- end
187
- end
188
- end
189
- end
190
- end
191
- end
@@ -1,129 +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
- "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
- logger.info "[#{stream}] #{text}"
71
- case text
72
- when /^user:/mi
73
- if variable(:scm_user)
74
- "#{variable(:scm_user)}\n"
75
- else
76
- raise "No variable :scm_user specified and Mercurial asked!\n" +
77
- "Prompt was: #{text}"
78
- end
79
- when /^password:/mi
80
- if variable(:scm_password)
81
- "#{variable(:scm_password)}\n"
82
- else
83
- raise "No variable :scm_password specified and Mercurial asked!\n" +
84
- "Prompt was: #{text}"
85
- end
86
- when /yes\/no/i
87
- "yes\n"
88
- end
89
- end
90
-
91
- private
92
-
93
- # Fine grained mercurial commands
94
- def clone(destination)
95
- scm :clone,
96
- verbose,
97
- "--noupdate", # do not update to tip when cloning is done
98
- repository, # clone which repository?
99
- destination # and put the clone where?
100
- end
101
-
102
- def pull(destination)
103
- scm :pull,
104
- verbose,
105
- "--repository #{destination}", # pull changes into what?
106
- repository # and pull the changes from?
107
- end
108
-
109
- def update(changeset, destination)
110
- scm :update,
111
- verbose,
112
- "--repository #{destination}", # update what?
113
- "--clean", # ignore untracked changes
114
- changeset # update to this changeset
115
- end
116
-
117
- # verbosity configuration grokking :)
118
- def verbose
119
- case variable(:scm_verbose)
120
- when nil: nil
121
- when false: "--quiet"
122
- else "--verbose"
123
- end
124
- end
125
-
126
- end
127
- end
128
- end
129
- end
@@ -1,126 +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, "-f")
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, "-f")
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, "-f")
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
- # Determines what the response should be for a particular bit of text
62
- # from the SCM. Password prompts, connection requests, passphrases,
63
- # etc. are handled here.
64
- def handle_data(state, stream, text)
65
- case text
66
- when /\(P4PASSWD\) invalid or unset\./i
67
- raise Capistrano::Error, "scm_password (or p4passwd) is incorrect or unset"
68
- when /Can.t create a new user.*/i
69
- raise Capistrano::Error, "scm_username (or p4user) is incorrect or unset"
70
- when /Perforce client error\:/i
71
- raise Capistrano::Error, "p4port is incorrect or unset"
72
- when /Client \'[\w\-\_\.]+\' unknown.*/i
73
- raise Capistrano::Error, "p4client is incorrect or unset"
74
- end
75
- end
76
-
77
- private
78
-
79
- # Builds the set of authentication switches that perforce understands.
80
- def authentication
81
- [ p4port && "-p #{p4port}",
82
- p4user && "-u #{p4user}",
83
- p4passwd && "-P #{p4passwd}",
84
- p4client && "-c #{p4client}" ].compact.join(" ")
85
- end
86
-
87
- # Returns the command that will sync the given revision to the given
88
- # destination directory with specific options. The perforce client has
89
- # a fixed destination so the files must be copied from there to their
90
- # intended resting place.
91
- def p4_sync(revision, destination, options="")
92
- p4client_root = "`#{command} #{authentication} client -o | grep ^Root | cut -f2`"
93
- scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}"
94
- end
95
-
96
- def p4client
97
- variable(:p4client)
98
- end
99
-
100
- def p4port
101
- variable(:p4port)
102
- end
103
-
104
- def p4user
105
- variable(:p4user) || variable(:scm_username)
106
- end
107
-
108
- def p4passwd
109
- variable(:p4passwd) || variable(:scm_password)
110
- end
111
-
112
- def rev_no(revision)
113
- case revision.to_s
114
- when "head"
115
- "#head"
116
- when /^\d+/
117
- "@#{revision}"
118
- else
119
- revision
120
- end
121
- end
122
- end
123
-
124
- end
125
- end
126
- end
@@ -1,114 +0,0 @@
1
- require 'capistrano/recipes/deploy/scm/base'
2
- require 'yaml'
3
-
4
- module Capistrano
5
- module Deploy
6
- module SCM
7
-
8
- # Implements the Capistrano SCM interface for the Subversion revision
9
- # control system (http://subversion.tigris.org).
10
- class Subversion < Base
11
- # Sets the default command name for this SCM. Users may override this
12
- # by setting the :scm_command variable.
13
- default_command "svn"
14
-
15
- # Subversion understands 'HEAD' to refer to the latest revision in the
16
- # repository.
17
- def head
18
- "HEAD"
19
- end
20
-
21
- # Returns the command that will check out the given revision to the
22
- # given destination.
23
- def checkout(revision, destination)
24
- scm :checkout, verbose, authentication, "-r#{revision}", repository, destination
25
- end
26
-
27
- # Returns the command that will do an "svn update" to the given
28
- # revision, for the working copy at the given destination.
29
- def sync(revision, destination)
30
- scm :update, verbose, authentication, "-r#{revision}", destination
31
- end
32
-
33
- # Returns the command that will do an "svn export" of the given revision
34
- # to the given destination.
35
- def export(revision, destination)
36
- scm :export, verbose, authentication, "-r#{revision}", repository, destination
37
- end
38
-
39
- # Returns the command that will do an "svn diff" for the two revisions.
40
- def diff(from, to=nil)
41
- scm :diff, repository, authentication, "-r#{from}:#{to || head}"
42
- end
43
-
44
- # Returns an "svn log" command for the two revisions.
45
- def log(from, to=nil)
46
- scm :log, repository, authentication, "-r#{from}:#{to || head}"
47
- end
48
-
49
- # Attempts to translate the given revision identifier to a "real"
50
- # revision. If the identifier is an integer, it will simply be returned.
51
- # Otherwise, this will yield a string of the commands it needs to be
52
- # executed (svn info), and will extract the revision from the response.
53
- def query_revision(revision)
54
- return revision if revision =~ /^\d+$/
55
- command = scm(:info, repository, authentication, "-r#{revision}")
56
- result = yield(command)
57
- yaml = YAML.load(result)
58
- raise "tried to run `#{command}' and got unexpected result #{result.inspect}" unless Hash === yaml
59
- yaml['Last Changed Rev'] || yaml['Revision']
60
- end
61
-
62
- # Increments the given revision number and returns it.
63
- def next_revision(revision)
64
- revision.to_i + 1
65
- end
66
-
67
- # Determines what the response should be for a particular bit of text
68
- # from the SCM. Password prompts, connection requests, passphrases,
69
- # etc. are handled here.
70
- def handle_data(state, stream, text)
71
- logger.info "[#{stream}] #{text}"
72
- case text
73
- when /\bpassword.*:/i
74
- # subversion is prompting for a password
75
- "#{variable(:scm_password) || variable(:password)}\n"
76
- when %r{\(yes/no\)}
77
- # subversion is asking whether or not to connect
78
- "yes\n"
79
- when /passphrase/i
80
- # subversion is asking for the passphrase for the user's key
81
- "#{variable(:scm_passphrase)}\n"
82
- when /The entry \'(.+?)\' is no longer a directory/
83
- raise Capisrano::Error, "subversion can't update because directory '#{$1}' was replaced. Please add it to svn:ignore."
84
- when /accept \(t\)emporarily/
85
- # subversion is asking whether to accept the certificate
86
- "t\n"
87
- end
88
- end
89
-
90
- private
91
-
92
- # If a username is configured for the SCM, return the command-line
93
- # switches for that. Note that we don't need to return the password
94
- # switch, since Capistrano will check for that prompt in the output
95
- # and will respond appropriately.
96
- def authentication
97
- username = variable(:scm_username)
98
- return "" unless username
99
- result = "--username #{variable(:scm_username)} "
100
- result << "--password #{variable(:scm_password)} " unless variable(:scm_prefer_prompt)
101
- result << "--no-auth-cache " unless variable(:scm_auth_cache)
102
- result
103
- end
104
-
105
- # If verbose output is requested, return nil, otherwise return the
106
- # command-line switch for "quiet" ("-q").
107
- def verbose
108
- variable(:scm_verbose) ? nil : "-q"
109
- end
110
- end
111
-
112
- end
113
- end
114
- end
@@ -1,19 +0,0 @@
1
- module Capistrano
2
- module Deploy
3
- module SCM
4
- def self.new(scm, config={})
5
- scm_file = "capistrano/recipes/deploy/scm/#{scm}"
6
- require(scm_file)
7
-
8
- scm_const = scm.to_s.capitalize.gsub(/_(.)/) { $1.upcase }
9
- if const_defined?(scm_const)
10
- const_get(scm_const).new(config)
11
- else
12
- raise Capistrano::Error, "could not find `#{name}::#{scm_const}' in `#{scm_file}'"
13
- end
14
- rescue LoadError
15
- raise Capistrano::Error, "could not find any SCM named `#{scm}'"
16
- end
17
- end
18
- end
19
- end
@@ -1,64 +0,0 @@
1
- require 'capistrano/recipes/deploy/dependencies'
2
-
3
- module Capistrano
4
- module Deploy
5
- module Strategy
6
-
7
- # This class defines the abstract interface for all Capistrano
8
- # deployment strategies. Subclasses must implement at least the
9
- # #deploy! method.
10
- class Base
11
- attr_reader :configuration
12
-
13
- # Instantiates a strategy with a reference to the given configuration.
14
- def initialize(config={})
15
- @configuration = config
16
- end
17
-
18
- # Executes the necessary commands to deploy the revision of the source
19
- # code identified by the +revision+ variable. Additionally, this
20
- # should write the value of the +revision+ variable to a file called
21
- # REVISION, in the base of the deployed revision. This file is used by
22
- # other tasks, to perform diffs and such.
23
- def deploy!
24
- raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}"
25
- end
26
-
27
- # Performs a check on the remote hosts to determine whether everything
28
- # is setup such that a deploy could succeed.
29
- def check!
30
- Dependencies.new(configuration) do |d|
31
- d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.")
32
- d.remote.writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.")
33
- d.remote.writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.")
34
- end
35
- end
36
-
37
- protected
38
-
39
- # This is to allow helper methods like "run" and "put" to be more
40
- # easily accessible to strategy implementations.
41
- def method_missing(sym, *args, &block)
42
- if configuration.respond_to?(sym)
43
- configuration.send(sym, *args, &block)
44
- else
45
- super
46
- end
47
- end
48
-
49
- private
50
-
51
- def logger
52
- @logger ||= configuration[:logger] || Capistrano::Logger.new(:output => STDOUT)
53
- end
54
-
55
- # The revision to deploy. Must return a real revision identifier,
56
- # and not a pseudo-id.
57
- def revision
58
- configuration[:real_revision]
59
- end
60
- end
61
-
62
- end
63
- end
64
- end
@@ -1,20 +0,0 @@
1
- require 'capistrano/recipes/deploy/strategy/remote'
2
-
3
- module Capistrano
4
- module Deploy
5
- module Strategy
6
-
7
- # Implements the deployment strategy which does an SCM checkout on each
8
- # target host. This is the default deployment strategy for Capistrano.
9
- class Checkout < Remote
10
- protected
11
-
12
- # Returns the SCM's checkout command for the revision to deploy.
13
- def command
14
- @command ||= source.checkout(revision, configuration[:release_path])
15
- end
16
- end
17
-
18
- end
19
- end
20
- end