capistrano 2.8.0 → 3.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.docker/Dockerfile +7 -0
- data/.docker/ssh_key_rsa +49 -0
- data/.docker/ssh_key_rsa.pub +1 -0
- data/.docker/ubuntu_setup.sh +23 -0
- data/.github/issue_template.md +19 -0
- data/.github/pull_request_template.md +22 -0
- data/.github/release-drafter.yml +25 -0
- data/.github/workflows/ci.yml +80 -0
- data/.github/workflows/release-drafter.yml +18 -0
- data/.gitignore +23 -8
- data/.rubocop.yml +62 -0
- data/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +63 -0
- data/DEVELOPMENT.md +112 -0
- data/Gemfile +42 -9
- data/LICENSE.txt +21 -0
- data/README.md +221 -0
- data/RELEASING.md +17 -0
- data/Rakefile +17 -8
- data/UPGRADING-3.7.md +86 -0
- data/bin/cap +2 -3
- data/bin/capify +7 -89
- data/capistrano.gemspec +29 -43
- data/docker-compose.yml +8 -0
- data/features/configuration.feature +28 -0
- data/features/deploy.feature +92 -0
- data/features/deploy_failure.feature +17 -0
- data/features/doctor.feature +11 -0
- data/features/installation.feature +21 -0
- data/features/sshconnect.feature +11 -0
- data/features/stage_failure.feature +9 -0
- data/features/step_definitions/assertions.rb +162 -0
- data/features/step_definitions/cap_commands.rb +21 -0
- data/features/step_definitions/setup.rb +91 -0
- data/features/subdirectory.feature +9 -0
- data/features/support/docker_gateway.rb +53 -0
- data/features/support/env.rb +1 -0
- data/features/support/remote_command_helpers.rb +29 -0
- data/features/support/remote_ssh_helpers.rb +33 -0
- data/lib/Capfile +3 -0
- data/lib/capistrano/all.rb +17 -0
- data/lib/capistrano/application.rb +153 -0
- data/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/lib/capistrano/configuration/filter.rb +26 -0
- data/lib/capistrano/configuration/host_filter.rb +29 -0
- data/lib/capistrano/configuration/null_filter.rb +9 -0
- data/lib/capistrano/configuration/plugin_installer.rb +51 -0
- data/lib/capistrano/configuration/question.rb +76 -0
- data/lib/capistrano/configuration/role_filter.rb +29 -0
- data/lib/capistrano/configuration/scm_resolver.rb +149 -0
- data/lib/capistrano/configuration/server.rb +137 -0
- data/lib/capistrano/configuration/servers.rb +56 -96
- data/lib/capistrano/configuration/validated_variables.rb +110 -0
- data/lib/capistrano/configuration/variables.rb +79 -94
- data/lib/capistrano/configuration.rb +178 -33
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +36 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/doctor/environment_doctor.rb +19 -0
- data/lib/capistrano/doctor/gems_doctor.rb +45 -0
- data/lib/capistrano/doctor/output_helpers.rb +79 -0
- data/lib/capistrano/doctor/servers_doctor.rb +105 -0
- data/lib/capistrano/doctor/variables_doctor.rb +74 -0
- data/lib/capistrano/doctor.rb +6 -0
- data/lib/capistrano/dotfile.rb +2 -0
- data/lib/capistrano/dsl/env.rb +43 -0
- data/lib/capistrano/dsl/paths.rb +89 -0
- data/lib/capistrano/dsl/stages.rb +31 -0
- data/lib/capistrano/dsl/task_enhancements.rb +61 -0
- data/lib/capistrano/dsl.rb +95 -0
- data/lib/capistrano/framework.rb +2 -0
- data/lib/capistrano/i18n.rb +46 -0
- data/lib/capistrano/immutable_task.rb +30 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/plugin.rb +95 -0
- data/lib/capistrano/proc_helpers.rb +13 -0
- data/lib/capistrano/scm/git.rb +105 -0
- data/lib/capistrano/scm/hg.rb +55 -0
- data/lib/capistrano/scm/plugin.rb +13 -0
- data/lib/capistrano/scm/svn.rb +56 -0
- data/lib/capistrano/scm/tasks/git.rake +84 -0
- data/lib/capistrano/scm/tasks/hg.rake +53 -0
- data/lib/capistrano/scm/tasks/svn.rake +53 -0
- data/lib/capistrano/scm.rb +115 -0
- data/lib/capistrano/setup.rb +36 -0
- data/lib/capistrano/tasks/console.rake +25 -0
- data/lib/capistrano/tasks/deploy.rake +280 -0
- data/lib/capistrano/tasks/doctor.rake +24 -0
- data/lib/capistrano/tasks/framework.rake +67 -0
- data/lib/capistrano/tasks/install.rake +41 -0
- data/lib/capistrano/templates/Capfile +38 -0
- data/lib/capistrano/templates/deploy.rb.erb +39 -0
- data/lib/capistrano/templates/stage.rb.erb +61 -0
- data/lib/capistrano/upload_task.rb +9 -0
- data/lib/capistrano/version.rb +1 -14
- data/lib/capistrano/version_validator.rb +32 -0
- data/lib/capistrano.rb +0 -3
- data/spec/integration/dsl_spec.rb +632 -0
- data/spec/integration_spec_helper.rb +5 -0
- data/spec/lib/capistrano/application_spec.rb +60 -0
- data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
- data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
- data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
- data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
- data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
- data/spec/lib/capistrano/configuration_spec.rb +357 -0
- data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
- data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
- data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
- data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
- data/spec/lib/capistrano/dsl_spec.rb +125 -0
- data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/spec/lib/capistrano/scm/git_spec.rb +194 -0
- data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
- data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
- data/spec/lib/capistrano/scm_spec.rb +103 -0
- data/spec/lib/capistrano/upload_task_spec.rb +19 -0
- data/spec/lib/capistrano/version_validator_spec.rb +118 -0
- data/spec/lib/capistrano_spec.rb +7 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/matchers.rb +5 -0
- data/spec/support/tasks/database.rake +11 -0
- data/spec/support/tasks/fail.rake +8 -0
- data/spec/support/tasks/failed.rake +5 -0
- data/spec/support/tasks/plugin.rake +6 -0
- data/spec/support/tasks/root.rake +11 -0
- data/spec/support/test_app.rb +205 -0
- metadata +234 -208
- data/.rvmrc +0 -1
- data/CHANGELOG +0 -954
- data/README.mdown +0 -76
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -85
- data/lib/capistrano/cli/help.rb +0 -125
- data/lib/capistrano/cli/help.txt +0 -81
- data/lib/capistrano/cli/options.rb +0 -243
- data/lib/capistrano/cli/ui.rb +0 -40
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -286
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -298
- data/lib/capistrano/configuration/callbacks.rb +0 -148
- data/lib/capistrano/configuration/connections.rb +0 -230
- data/lib/capistrano/configuration/execution.rb +0 -143
- data/lib/capistrano/configuration/loading.rb +0 -197
- data/lib/capistrano/configuration/namespaces.rb +0 -197
- data/lib/capistrano/configuration/roles.rb +0 -73
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/logger.rb +0 -59
- data/lib/capistrano/processable.rb +0 -53
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -57
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
- data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/deploy.rb +0 -568
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/role.rb +0 -102
- data/lib/capistrano/server_definition.rb +0 -56
- data/lib/capistrano/shell.rb +0 -260
- data/lib/capistrano/ssh.rb +0 -101
- data/lib/capistrano/task_definition.rb +0 -75
- data/lib/capistrano/transfer.rb +0 -216
- data/rvmrc.sample +0 -1
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -165
- data/test/cli/options_test.rb +0 -329
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -289
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -65
- data/test/configuration/actions/invocation_test.rb +0 -247
- data/test/configuration/callbacks_test.rb +0 -220
- data/test/configuration/connections_test.rb +0 -420
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -132
- data/test/configuration/namespace_dsl_test.rb +0 -311
- data/test/configuration/roles_test.rb +0 -144
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -88
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -135
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/bzr_test.rb +0 -51
- data/test/deploy/scm/darcs_test.rb +0 -37
- data/test/deploy/scm/git_test.rb +0 -184
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/subversion_test.rb +0 -32
- data/test/deploy/strategy/copy_test.rb +0 -321
- data/test/extensions_test.rb +0 -69
- data/test/fixtures/cli_integration.rb +0 -5
- data/test/fixtures/config.rb +0 -5
- data/test/fixtures/custom.rb +0 -3
- data/test/logger_test.rb +0 -123
- data/test/recipes_test.rb +0 -25
- data/test/role_test.rb +0 -11
- data/test/server_definition_test.rb +0 -121
- data/test/shell_test.rb +0 -90
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -116
- data/test/transfer_test.rb +0 -160
- data/test/utils.rb +0 -37
@@ -1,196 +0,0 @@
|
|
1
|
-
module Capistrano
|
2
|
-
module Deploy
|
3
|
-
module SCM
|
4
|
-
|
5
|
-
# The ancestor class for all Capistrano SCM implementations. It provides
|
6
|
-
# minimal infrastructure for subclasses to build upon and override.
|
7
|
-
#
|
8
|
-
# Note that subclasses that implement this abstract class only return
|
9
|
-
# the commands that need to be executed--they do not execute the commands
|
10
|
-
# themselves. In this way, the deployment method may execute the commands
|
11
|
-
# either locally or remotely, as necessary.
|
12
|
-
class Base
|
13
|
-
class << self
|
14
|
-
# If no parameters are given, it returns the current configured
|
15
|
-
# name of the command-line utility of this SCM. If a parameter is
|
16
|
-
# given, the defeault command is set to that value.
|
17
|
-
def default_command(value=nil)
|
18
|
-
if value
|
19
|
-
@default_command = value
|
20
|
-
else
|
21
|
-
@default_command
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Wraps an SCM instance and forces all messages sent to it to be
|
27
|
-
# relayed to the underlying SCM instance, in "local" mode. See
|
28
|
-
# Base#local.
|
29
|
-
class LocalProxy
|
30
|
-
def initialize(scm)
|
31
|
-
@scm = scm
|
32
|
-
end
|
33
|
-
|
34
|
-
def method_missing(sym, *args, &block)
|
35
|
-
@scm.local { return @scm.send(sym, *args, &block) }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# The options available for this SCM instance to reference. Should be
|
40
|
-
# treated like a hash.
|
41
|
-
attr_reader :configuration
|
42
|
-
|
43
|
-
# Creates a new SCM instance with the given configuration options.
|
44
|
-
def initialize(configuration={})
|
45
|
-
@configuration = configuration
|
46
|
-
end
|
47
|
-
|
48
|
-
# Returns a proxy that wraps the SCM instance and forces it to operate
|
49
|
-
# in "local" mode, which changes how variables are looked up in the
|
50
|
-
# configuration. Normally, if the value of a variable "foo" is needed,
|
51
|
-
# it is queried for in the configuration as "foo". However, in "local"
|
52
|
-
# mode, first "local_foo" would be looked for, and only if it is not
|
53
|
-
# found would "foo" be used. This allows for both (e.g.) "scm_command"
|
54
|
-
# and "local_scm_command" to be set, if the two differ.
|
55
|
-
#
|
56
|
-
# Alternatively, it may be called with a block, and for the duration of
|
57
|
-
# the block, all requests on this configuration object will be
|
58
|
-
# considered local.
|
59
|
-
def local
|
60
|
-
if block_given?
|
61
|
-
begin
|
62
|
-
saved, @local_mode = @local_mode, true
|
63
|
-
yield
|
64
|
-
ensure
|
65
|
-
@local_mode = saved
|
66
|
-
end
|
67
|
-
else
|
68
|
-
LocalProxy.new(self)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# Returns true if running in "local" mode. See #local.
|
73
|
-
def local?
|
74
|
-
@local_mode
|
75
|
-
end
|
76
|
-
|
77
|
-
# Returns the string used to identify the latest revision in the
|
78
|
-
# repository. This will be passed as the "revision" parameter of
|
79
|
-
# the methods below.
|
80
|
-
def head
|
81
|
-
raise NotImplementedError, "`head' is not implemented by #{self.class.name}"
|
82
|
-
end
|
83
|
-
|
84
|
-
# Checkout a copy of the repository, at the given +revision+, to the
|
85
|
-
# given +destination+. The checkout is suitable for doing development
|
86
|
-
# work in, e.g. allowing subsequent commits and updates.
|
87
|
-
def checkout(revision, destination)
|
88
|
-
raise NotImplementedError, "`checkout' is not implemented by #{self.class.name}"
|
89
|
-
end
|
90
|
-
|
91
|
-
# Resynchronize the working copy in +destination+ to the specified
|
92
|
-
# +revision+.
|
93
|
-
def sync(revision, destination)
|
94
|
-
raise NotImplementedError, "`sync' is not implemented by #{self.class.name}"
|
95
|
-
end
|
96
|
-
|
97
|
-
# Compute the difference between the two revisions, +from+ and +to+.
|
98
|
-
def diff(from, to=nil)
|
99
|
-
raise NotImplementedError, "`diff' is not implemented by #{self.class.name}"
|
100
|
-
end
|
101
|
-
|
102
|
-
# Return a log of all changes between the two specified revisions,
|
103
|
-
# +from+ and +to+, inclusive.
|
104
|
-
def log(from, to=nil)
|
105
|
-
raise NotImplementedError, "`log' is not implemented by #{self.class.name}"
|
106
|
-
end
|
107
|
-
|
108
|
-
# If the given revision represents a "real" revision, this should
|
109
|
-
# simply return the revision value. If it represends a pseudo-revision
|
110
|
-
# (like Subversions "HEAD" identifier), it should yield a string
|
111
|
-
# containing the commands that, when executed will return a string
|
112
|
-
# that this method can then extract the real revision from.
|
113
|
-
def query_revision(revision)
|
114
|
-
raise NotImplementedError, "`query_revision' is not implemented by #{self.class.name}"
|
115
|
-
end
|
116
|
-
|
117
|
-
# Returns the revision number immediately following revision, if at
|
118
|
-
# all possible. A block should always be passed to this method, which
|
119
|
-
# accepts a command to invoke and returns the result, although a
|
120
|
-
# particular SCM's implementation is not required to invoke the block.
|
121
|
-
#
|
122
|
-
# By default, this method simply returns the revision itself. If a
|
123
|
-
# particular SCM is able to determine a subsequent revision given a
|
124
|
-
# revision identifier, it should override this method.
|
125
|
-
def next_revision(revision)
|
126
|
-
revision
|
127
|
-
end
|
128
|
-
|
129
|
-
# Should analyze the given text and determine whether or not a
|
130
|
-
# response is expected, and if so, return the appropriate response.
|
131
|
-
# If no response is expected, return nil. The +state+ parameter is a
|
132
|
-
# hash that may be used to preserve state between calls. This method
|
133
|
-
# is used to define how Capistrano should respond to common prompts
|
134
|
-
# and messages from the SCM, like password prompts and such. By
|
135
|
-
# default, the output is simply displayed.
|
136
|
-
def handle_data(state, stream, text)
|
137
|
-
logger.info "[#{stream}] #{text}"
|
138
|
-
nil
|
139
|
-
end
|
140
|
-
|
141
|
-
# Returns the name of the command-line utility for this SCM. It first
|
142
|
-
# looks at the :scm_command variable, and if it does not exist, it
|
143
|
-
# then falls back to whatever was defined by +default_command+.
|
144
|
-
#
|
145
|
-
# If scm_command is set to :default, the default_command will be
|
146
|
-
# returned.
|
147
|
-
def command
|
148
|
-
command = variable(:scm_command)
|
149
|
-
command = nil if command == :default
|
150
|
-
command || default_command
|
151
|
-
end
|
152
|
-
|
153
|
-
# A helper method that can be used to define SCM commands naturally.
|
154
|
-
# It returns a single string with all arguments joined by spaces,
|
155
|
-
# with the scm command prefixed onto it.
|
156
|
-
def scm(*args)
|
157
|
-
[command, *args].compact.join(" ")
|
158
|
-
end
|
159
|
-
|
160
|
-
private
|
161
|
-
|
162
|
-
# A helper for accessing variable values, which takes into
|
163
|
-
# consideration the current mode ("normal" vs. "local").
|
164
|
-
def variable(name, default = nil)
|
165
|
-
if local? && configuration.exists?("local_#{name}".to_sym)
|
166
|
-
return configuration["local_#{name}".to_sym] || default
|
167
|
-
else
|
168
|
-
configuration[name] || default
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
# A reference to a Logger instance that the SCM can use to log
|
173
|
-
# activity.
|
174
|
-
def logger
|
175
|
-
@logger ||= variable(:logger) || Capistrano::Logger.new(:output => STDOUT)
|
176
|
-
end
|
177
|
-
|
178
|
-
# A helper for accessing the default command name for this SCM. It
|
179
|
-
# simply delegates to the class' +default_command+ method.
|
180
|
-
def default_command
|
181
|
-
self.class.default_command
|
182
|
-
end
|
183
|
-
|
184
|
-
# A convenience method for accessing the declared repository value.
|
185
|
-
def repository
|
186
|
-
variable(:repository)
|
187
|
-
end
|
188
|
-
|
189
|
-
def arguments
|
190
|
-
variable(:scm_arguments)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'capistrano/recipes/deploy/scm/base'
|
2
|
-
|
3
|
-
module Capistrano
|
4
|
-
module Deploy
|
5
|
-
module SCM
|
6
|
-
|
7
|
-
# Implements the Capistrano SCM interface for the Bazaar-NG revision
|
8
|
-
# control system (http://bazaar-vcs.org/).
|
9
|
-
class Bzr < Base
|
10
|
-
# Sets the default command name for this SCM. Users may override this
|
11
|
-
# by setting the :scm_command variable.
|
12
|
-
default_command "bzr"
|
13
|
-
|
14
|
-
# Bazaar-NG doesn't support any pseudo-id's, so we'll use the convention
|
15
|
-
# in this adapter that the :head symbol means the most recently
|
16
|
-
# committed revision.
|
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, "--lightweight", revswitch(revision), repository, destination
|
25
|
-
end
|
26
|
-
|
27
|
-
# The bzr 'update' command does not support updating to a specific
|
28
|
-
# revision, so this just does update, followed by revert (unless
|
29
|
-
# updating to head).
|
30
|
-
def sync(revision, destination)
|
31
|
-
commands = [scm(:update, destination)]
|
32
|
-
commands << [scm(:revert, revswitch(revision), destination)] if revision != head
|
33
|
-
commands.join(" && ")
|
34
|
-
end
|
35
|
-
|
36
|
-
# The bzr 'export' does an export similar to other SCM systems
|
37
|
-
def export(revision, destination)
|
38
|
-
scm :export, revswitch(revision), destination, repository
|
39
|
-
end
|
40
|
-
|
41
|
-
# The bzr "diff" command doesn't accept a repository argument, so it
|
42
|
-
# must be run from within a working tree.
|
43
|
-
def diff(from, to=nil)
|
44
|
-
switch = "-r#{from}"
|
45
|
-
switch << "..#{to}" if to
|
46
|
-
|
47
|
-
scm :diff, switch
|
48
|
-
end
|
49
|
-
|
50
|
-
# Returns a log of changes between the two revisions (inclusive).
|
51
|
-
def log(from, to=nil)
|
52
|
-
scm :log, "--short", "-r#{from}..#{to}", repository
|
53
|
-
end
|
54
|
-
|
55
|
-
# Attempts to translate the given revision identifier to a "real"
|
56
|
-
# revision. If the identifier is :head, the "bzr revno" command will
|
57
|
-
# be yielded, and the block must execute the command and return the
|
58
|
-
# output. The revision will be extracted from the output and returned.
|
59
|
-
# If the 'revision' argument, on the other hand, is not :head, it is
|
60
|
-
# simply returned.
|
61
|
-
def query_revision(revision)
|
62
|
-
return revision unless :head == revision
|
63
|
-
|
64
|
-
command = scm('revno', repository)
|
65
|
-
result = yield(command)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Increments the given revision number and returns it.
|
69
|
-
def next_revision(revision)
|
70
|
-
revision.to_i + 1
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def revswitch(revision)
|
76
|
-
if revision == :head || revision.nil?
|
77
|
-
nil
|
78
|
-
else
|
79
|
-
"-r #{revision}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
require 'capistrano/recipes/deploy/scm/base'
|
2
|
-
|
3
|
-
module Capistrano
|
4
|
-
module Deploy
|
5
|
-
module SCM
|
6
|
-
|
7
|
-
# Implements the Capistrano SCM interface for the CVS revision
|
8
|
-
# control system.
|
9
|
-
class Cvs < Base
|
10
|
-
# Sets the default command name for this SCM. Users may override this
|
11
|
-
# by setting the :scm_command variable.
|
12
|
-
default_command "cvs"
|
13
|
-
|
14
|
-
# CVS understands 'HEAD' to refer to the latest revision in the
|
15
|
-
# repository.
|
16
|
-
def head
|
17
|
-
"HEAD"
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns the command that will check out the given revision to the
|
21
|
-
# given destination.
|
22
|
-
def checkout(revision, destination)
|
23
|
-
[ prep_destination(destination),
|
24
|
-
scm(verbose, cvs_root, :checkout, cvs_revision(revision), cvs_destination(destination), variable(:scm_module))
|
25
|
-
].join(' && ')
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns the command that will do an "cvs update" to the given
|
29
|
-
# revision, for the working copy at the given destination.
|
30
|
-
def sync(revision, destination)
|
31
|
-
[ prep_destination(destination),
|
32
|
-
scm(verbose, cvs_root, :update, cvs_revision(revision), cvs_destination(destination))
|
33
|
-
].join(' && ')
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns the command that will do an "cvs export" of the given revision
|
37
|
-
# to the given destination.
|
38
|
-
def export(revision, destination)
|
39
|
-
[ prep_destination(destination),
|
40
|
-
scm(verbose, cvs_root, :export, cvs_revision(revision), cvs_destination(destination), variable(:scm_module))
|
41
|
-
].join(' && ')
|
42
|
-
end
|
43
|
-
|
44
|
-
# Returns the command that will do an "cvs diff" for the two revisions.
|
45
|
-
def diff(from, to=nil)
|
46
|
-
rev_type = revision_type(from)
|
47
|
-
if rev_type == :date
|
48
|
-
range_args = "-D '#{from}' -D '#{to || 'now'}'"
|
49
|
-
else
|
50
|
-
range_args = "-r '#{from}' -r '#{to || head}'"
|
51
|
-
end
|
52
|
-
scm cvs_root, :diff, range_args
|
53
|
-
end
|
54
|
-
|
55
|
-
# Returns an "cvs log" command for the two revisions.
|
56
|
-
def log(from, to=nil)
|
57
|
-
rev_type = revision_type(from)
|
58
|
-
if rev_type == :date
|
59
|
-
range_arg = "-d '#{from}<#{to || 'now'}'"
|
60
|
-
else
|
61
|
-
range_arg = "-r '#{from}:#{to || head}'"
|
62
|
-
end
|
63
|
-
scm cvs_root, :log, range_arg
|
64
|
-
end
|
65
|
-
|
66
|
-
# Unfortunately, cvs doesn't support the concept of a revision number like
|
67
|
-
# subversion and other SCM's do. For now, we'll rely on getting the timestamp
|
68
|
-
# of the latest checkin under the revision that's passed to us.
|
69
|
-
def query_revision(revision)
|
70
|
-
return revision if revision_type(revision) == :date
|
71
|
-
revision = yield(scm(cvs_root, :log, "-r#{revision}")).
|
72
|
-
split("\n").
|
73
|
-
select { |line| line =~ /^date:/ }.
|
74
|
-
map { |line| line[/^date: (.*?);/, 1] }.
|
75
|
-
sort.last + " UTC"
|
76
|
-
return revision
|
77
|
-
end
|
78
|
-
|
79
|
-
# Determines what the response should be for a particular bit of text
|
80
|
-
# from the SCM. Password prompts, connection requests, passphrases,
|
81
|
-
# etc. are handled here.
|
82
|
-
def handle_data(state, stream, text)
|
83
|
-
logger.info "[#{stream}] #{text}"
|
84
|
-
case text
|
85
|
-
when /\bpassword.*:/i
|
86
|
-
# prompting for a password
|
87
|
-
"#{variable(:scm_password) || variable(:password)}\n"
|
88
|
-
when %r{\(yes/no\)}
|
89
|
-
# let's be agreeable...
|
90
|
-
"yes\n"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
# Constructs the CVSROOT command-line option
|
97
|
-
def cvs_root
|
98
|
-
root = ""
|
99
|
-
root << "-d #{repository} " if repository
|
100
|
-
root
|
101
|
-
end
|
102
|
-
|
103
|
-
# Constructs the destination dir command-line option
|
104
|
-
def cvs_destination(destination)
|
105
|
-
dest = ""
|
106
|
-
if destination
|
107
|
-
dest_parts = destination.split(/\//);
|
108
|
-
dest << "-d #{dest_parts.pop}"
|
109
|
-
end
|
110
|
-
dest
|
111
|
-
end
|
112
|
-
|
113
|
-
# attempts to guess what type of revision we're working with
|
114
|
-
def revision_type(rev)
|
115
|
-
return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} UTC$/ # i.e 2007-05-15 08:13:25 UTC
|
116
|
-
return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/ # i.e 2007-05-15 08:13:25
|
117
|
-
return :revision if rev =~ /^\d/ # i.e. 1.2.1
|
118
|
-
return :tag # i.e. RELEASE_1_2
|
119
|
-
end
|
120
|
-
|
121
|
-
# constructs the appropriate command-line switch for specifying a
|
122
|
-
# "revision" in CVS. This could be a tag, branch, revision (i.e. 1.3)
|
123
|
-
# or a date (to be used with -d)
|
124
|
-
def cvs_revision(rev)
|
125
|
-
revision = ""
|
126
|
-
revision << case revision_type(rev)
|
127
|
-
when :date
|
128
|
-
"-D \"#{rev}\"" if revision_type(rev) == :date
|
129
|
-
when :revision
|
130
|
-
"-r #{rev}"
|
131
|
-
else
|
132
|
-
"-r #{head}"
|
133
|
-
end
|
134
|
-
return revision
|
135
|
-
end
|
136
|
-
|
137
|
-
# If verbose output is requested, return nil, otherwise return the
|
138
|
-
# command-line switch for "quiet" ("-Q").
|
139
|
-
def verbose
|
140
|
-
variable(:scm_verbose) ? nil : "-Q"
|
141
|
-
end
|
142
|
-
|
143
|
-
def prep_destination(destination)
|
144
|
-
dest_parts = destination.split(/\//);
|
145
|
-
checkout_dir = dest_parts.pop
|
146
|
-
dest = dest_parts.join('/')
|
147
|
-
"mkdir -p #{ dest } && cd #{ dest }"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'capistrano/recipes/deploy/scm/base'
|
2
|
-
|
3
|
-
module Capistrano
|
4
|
-
module Deploy
|
5
|
-
module SCM
|
6
|
-
|
7
|
-
# Implements the Capistrano SCM interface for the darcs revision
|
8
|
-
# control system (http://www.abridgegame.org/darcs/).
|
9
|
-
class Darcs < Base
|
10
|
-
# Sets the default command name for this SCM. Users may override this
|
11
|
-
# by setting the :scm_command variable.
|
12
|
-
default_command "darcs"
|
13
|
-
|
14
|
-
# Because darcs does not have any support for pseudo-ids, we'll just
|
15
|
-
# return something here that we can use in the helpers below for
|
16
|
-
# determining whether we need to look up the latest revision.
|
17
|
-
def head
|
18
|
-
:head
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_match(revision)
|
22
|
-
if revision.nil? || revision == self.head
|
23
|
-
nil
|
24
|
-
else
|
25
|
-
"--to-match='hash #{revision}'"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Returns the command that will check out the given revision to the
|
30
|
-
# given destination. The 'revision' parameter must be the 'hash' value
|
31
|
-
# for the revision in question, as given by 'darcs changes --xml-output'.
|
32
|
-
def checkout(revision, destination)
|
33
|
-
scm :get, *[verbose,
|
34
|
-
"--repo-name=#{destination}",
|
35
|
-
to_match(revision),
|
36
|
-
repository].compact
|
37
|
-
end
|
38
|
-
|
39
|
-
# Tries to update the destination repository in-place, to bring it up
|
40
|
-
# to the given revision. Note that because darcs' "pull" operation
|
41
|
-
# does not support a "to-match" argument (or similar), this basically
|
42
|
-
# nukes the destination directory and re-gets it.
|
43
|
-
def sync(revision, destination)
|
44
|
-
["rm -rf #{destination}", checkout(revision, destination)].join(" && ")
|
45
|
-
end
|
46
|
-
|
47
|
-
# Darcs does not have a real 'export' option; there is 'darcs dist',
|
48
|
-
# but that presupposes a utility that can untar and ungzip the dist
|
49
|
-
# file. We'll cheat and just do a get, followed by a deletion of the
|
50
|
-
# _darcs metadata directory.
|
51
|
-
def export(revision, destination)
|
52
|
-
[checkout(revision, destination), "rm -rf #{destination}/_darcs"].join(" && ")
|
53
|
-
end
|
54
|
-
|
55
|
-
# Returns the command that will do a "darcs diff" for the two revisions.
|
56
|
-
# Each revision must be the 'hash' identifier of a darcs revision.
|
57
|
-
def diff(from, to=nil)
|
58
|
-
scm :diff, "--from-match 'hash #{from}'", to && "--to-match 'hash #{to}'"
|
59
|
-
end
|
60
|
-
|
61
|
-
# Returns the log of changes between the two revisions. Each revision
|
62
|
-
# must be the 'hash' identifier of a darcs revision.
|
63
|
-
def log(from, to=nil)
|
64
|
-
scm :changes, "--from-match 'hash #{from}'", to && "--to-match 'hash #{to}'", "--repo=#{repository}"
|
65
|
-
end
|
66
|
-
|
67
|
-
# Attempts to translate the given revision identifier to a "real"
|
68
|
-
# revision. If the identifier is a symbol, it is assumed to be a
|
69
|
-
# pseudo-id. Otherwise, it will be immediately returned. If it is a
|
70
|
-
# pseudo-id, a set of commands to execute will be yielded, and the
|
71
|
-
# result of executing those commands must be returned by the block.
|
72
|
-
# This method will then extract the actual revision hash from the
|
73
|
-
# returned data.
|
74
|
-
def query_revision(revision)
|
75
|
-
case revision
|
76
|
-
when :head
|
77
|
-
xml = yield(scm(:changes, "--last 1", "--xml-output", "--repo=#{repository}"))
|
78
|
-
return xml[/hash='(.*?)'/, 1]
|
79
|
-
else return revision
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def verbose
|
86
|
-
case variable(:scm_verbose)
|
87
|
-
when nil then "-q"
|
88
|
-
when false then nil
|
89
|
-
else "-v"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|