capistrano 2.15.11 → 3.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +17 -8
- data/Gemfile +1 -12
- data/LICENSE.txt +18 -0
- data/README.md +65 -68
- data/Rakefile +4 -10
- data/bin/cap +2 -3
- data/bin/capify +7 -91
- data/capistrano.gemspec +20 -34
- data/lib/Capfile +2 -0
- data/lib/capistrano/application.rb +28 -0
- data/lib/capistrano/bundler.rb +1 -0
- data/lib/capistrano/configuration/question.rb +42 -0
- data/lib/capistrano/configuration/server.rb +24 -0
- data/lib/capistrano/configuration/servers.rb +43 -95
- data/lib/capistrano/configuration.rb +81 -44
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +11 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/dotfile.rb +3 -0
- data/lib/capistrano/dsl/env.rb +57 -0
- data/lib/capistrano/dsl/paths.rb +74 -0
- data/lib/capistrano/dsl/stages.rb +15 -0
- data/lib/capistrano/dsl/task_enhancements.rb +15 -0
- data/lib/capistrano/dsl.rb +38 -0
- data/lib/capistrano/git.rb +1 -0
- data/lib/capistrano/i18n.rb +33 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/setup.rb +17 -0
- data/lib/capistrano/tasks/bundler.rake +13 -0
- data/lib/capistrano/tasks/console.rake +21 -0
- data/lib/capistrano/tasks/deploy.rake +153 -0
- data/lib/capistrano/tasks/framework.rake +45 -0
- data/lib/capistrano/tasks/git.rake +65 -0
- data/lib/capistrano/tasks/install.rake +39 -0
- data/lib/capistrano/templates/Capfile +43 -0
- data/lib/capistrano/templates/deploy.rb.erb +17 -0
- data/lib/capistrano/templates/stage.rb.erb +20 -0
- data/lib/capistrano/version.rb +1 -11
- data/lib/capistrano.rb +9 -3
- data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +48 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +79 -0
- data/spec/lib/capistrano/configuration_spec.rb +80 -0
- data/spec/lib/capistrano/dsl/env_spec.rb +83 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
- data/spec/lib/capistrano/dsl_spec.rb +51 -0
- data/spec/lib/capistrano_spec.rb +8 -0
- data/spec/spec_helper.rb +14 -0
- metadata +89 -215
- data/.travis.yml +0 -9
- data/CHANGELOG +0 -1203
- 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 -303
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -50
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -329
- data/lib/capistrano/configuration/alias_task.rb +0 -26
- data/lib/capistrano/configuration/callbacks.rb +0 -147
- data/lib/capistrano/configuration/connections.rb +0 -237
- data/lib/capistrano/configuration/execution.rb +0 -142
- data/lib/capistrano/configuration/loading.rb +0 -205
- data/lib/capistrano/configuration/log_formatters.rb +0 -75
- data/lib/capistrano/configuration/namespaces.rb +0 -223
- data/lib/capistrano/configuration/roles.rb +0 -83
- data/lib/capistrano/configuration/variables.rb +0 -127
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/multistage.rb +0 -67
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +0 -8
- data/lib/capistrano/logger.rb +0 -166
- data/lib/capistrano/processable.rb +0 -55
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -202
- 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 -117
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -200
- 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 -299
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -55
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -152
- 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 -92
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -338
- 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/unshared_remote_cache.rb +0 -21
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -20
- data/lib/capistrano/recipes/deploy.rb +0 -625
- 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 -265
- data/lib/capistrano/ssh.rb +0 -95
- data/lib/capistrano/task_definition.rb +0 -77
- data/lib/capistrano/transfer.rb +0 -218
- 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 -322
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -76
- data/test/configuration/actions/invocation_test.rb +0 -306
- data/test/configuration/alias_task_test.rb +0 -118
- data/test/configuration/callbacks_test.rb +0 -201
- data/test/configuration/connections_test.rb +0 -439
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -148
- data/test/configuration/namespace_dsl_test.rb +0 -332
- data/test/configuration/roles_test.rb +0 -157
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -77
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -146
- 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 -274
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/perforce_test.rb +0 -23
- data/test/deploy/scm/subversion_test.rb +0 -68
- data/test/deploy/strategy/copy_test.rb +0 -360
- 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_formatting_test.rb +0 -149
- data/test/logger_test.rb +0 -134
- 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 -96
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -117
- data/test/transfer_test.rb +0 -168
- data/test/utils.rb +0 -37
- data/test/version_test.rb +0 -11
|
@@ -1,152 +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}",
|
|
90
|
-
p4charset && "-C #{p4charset}" ].compact.join(" ")
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Returns the command that will sync the given revision to the given
|
|
94
|
-
# destination directory with specific options. The perforce client has
|
|
95
|
-
# a fixed destination so the files must be copied from there to their
|
|
96
|
-
# intended resting place.
|
|
97
|
-
def p4_sync(revision, destination, options="")
|
|
98
|
-
scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}"
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def p4client
|
|
102
|
-
variable(:p4client)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def p4port
|
|
106
|
-
variable(:p4port)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def p4user
|
|
110
|
-
variable(:p4user) || variable(:scm_username)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def p4passwd
|
|
114
|
-
variable(:p4passwd) || variable(:scm_password)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def p4charset
|
|
118
|
-
variable(:p4charset)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def p4sync_flags
|
|
122
|
-
variable(:p4sync_flags) || "-f"
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def p4client_root
|
|
126
|
-
variable(:p4client_root) || "`#{command} #{authentication} client -o | grep ^Root | cut -f2`"
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def rev_no(revision)
|
|
130
|
-
if variable(:p4_label)
|
|
131
|
-
p4_label = if variable(:p4_label) =~ /\A@/
|
|
132
|
-
variable(:p4_label)
|
|
133
|
-
else
|
|
134
|
-
"@#{variable(:p4_label)}"
|
|
135
|
-
end
|
|
136
|
-
return p4_label
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
case revision.to_s
|
|
140
|
-
when "head"
|
|
141
|
-
"#head"
|
|
142
|
-
when /^\d+/
|
|
143
|
-
"@#{revision}"
|
|
144
|
-
else
|
|
145
|
-
revision
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
@@ -1,121 +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, arguments, arguments(: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 :switch, arguments, verbose, authentication, "-r#{revision}", repository, 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, arguments, arguments(: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, arguments(:diff), 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, arguments(:log), 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, arguments, arguments(: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'] || 0).to_i, (yaml['Revision'] || 0).to_i ].max
|
|
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
|
-
host = state[:channel][:host]
|
|
72
|
-
logger.info "[#{host} :: #{stream}] #{text}"
|
|
73
|
-
case text
|
|
74
|
-
when /\bpassword.*:/i
|
|
75
|
-
# subversion is prompting for a password
|
|
76
|
-
%("#{scm_password_prompt}"\n)
|
|
77
|
-
when %r{\(yes/no\)}
|
|
78
|
-
# subversion is asking whether or not to connect
|
|
79
|
-
"yes\n"
|
|
80
|
-
when /passphrase/i
|
|
81
|
-
# subversion is asking for the passphrase for the user's key
|
|
82
|
-
%("#{variable(:scm_passphrase)}"\n)
|
|
83
|
-
when /The entry \'(.+?)\' is no longer a directory/
|
|
84
|
-
raise Capistrano::Error, "subversion can't update because directory '#{$1}' was replaced. Please add it to svn:ignore."
|
|
85
|
-
when /accept \(t\)emporarily/
|
|
86
|
-
# subversion is asking whether to accept the certificate
|
|
87
|
-
"t\n"
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
private
|
|
92
|
-
|
|
93
|
-
# If a username is configured for the SCM, return the command-line
|
|
94
|
-
# switches for that. Note that we don't need to return the password
|
|
95
|
-
# switch, since Capistrano will check for that prompt in the output
|
|
96
|
-
# and will respond appropriately.
|
|
97
|
-
def authentication
|
|
98
|
-
username = variable(:scm_username)
|
|
99
|
-
return "" unless username
|
|
100
|
-
result = %(--username "#{variable(:scm_username)}")
|
|
101
|
-
result << %( --password "#{variable(:scm_password)}") unless variable(:scm_auth_cache) || variable(:scm_prefer_prompt)
|
|
102
|
-
result << " --no-auth-cache " unless variable(:scm_auth_cache)
|
|
103
|
-
result
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# If verbose output is requested, return nil, otherwise return the
|
|
107
|
-
# command-line switch for "quiet" ("-q").
|
|
108
|
-
def verbose
|
|
109
|
-
variable(:scm_verbose) ? nil : "-q"
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def scm_password_prompt
|
|
113
|
-
@scm_password_prompt ||= variable(:scm_password) ||
|
|
114
|
-
variable(:password) ||
|
|
115
|
-
Capistrano::CLI.password_prompt("Subversion password: ")
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
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,92 +0,0 @@
|
|
|
1
|
-
require 'benchmark'
|
|
2
|
-
require 'capistrano/recipes/deploy/dependencies'
|
|
3
|
-
|
|
4
|
-
module Capistrano
|
|
5
|
-
module Deploy
|
|
6
|
-
module Strategy
|
|
7
|
-
|
|
8
|
-
# This class defines the abstract interface for all Capistrano
|
|
9
|
-
# deployment strategies. Subclasses must implement at least the
|
|
10
|
-
# #deploy! method.
|
|
11
|
-
class Base
|
|
12
|
-
attr_reader :configuration
|
|
13
|
-
|
|
14
|
-
# Instantiates a strategy with a reference to the given configuration.
|
|
15
|
-
def initialize(config={})
|
|
16
|
-
@configuration = config
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Executes the necessary commands to deploy the revision of the source
|
|
20
|
-
# code identified by the +revision+ variable. Additionally, this
|
|
21
|
-
# should write the value of the +revision+ variable to a file called
|
|
22
|
-
# REVISION, in the base of the deployed revision. This file is used by
|
|
23
|
-
# other tasks, to perform diffs and such.
|
|
24
|
-
def deploy!
|
|
25
|
-
raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Performs a check on the remote hosts to determine whether everything
|
|
29
|
-
# is setup such that a deploy could succeed.
|
|
30
|
-
def check!
|
|
31
|
-
Dependencies.new(configuration) do |d|
|
|
32
|
-
if exists?(:stage)
|
|
33
|
-
d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap #{configuration[:stage]} deploy:setup'.")
|
|
34
|
-
else
|
|
35
|
-
d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.")
|
|
36
|
-
end
|
|
37
|
-
d.remote.writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.")
|
|
38
|
-
d.remote.writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.")
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
protected
|
|
43
|
-
|
|
44
|
-
# This is to allow helper methods like "run" and "put" to be more
|
|
45
|
-
# easily accessible to strategy implementations.
|
|
46
|
-
def method_missing(sym, *args, &block)
|
|
47
|
-
if configuration.respond_to?(sym)
|
|
48
|
-
configuration.send(sym, *args, &block)
|
|
49
|
-
else
|
|
50
|
-
super
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# A wrapper for Kernel#system that logs the command being executed.
|
|
55
|
-
def system(*args)
|
|
56
|
-
cmd = args.join(' ')
|
|
57
|
-
result = nil
|
|
58
|
-
if RUBY_PLATFORM =~ /win32/
|
|
59
|
-
cmd = cmd.split(/\s+/).collect {|w| w.match(/^[\w+]+:\/\//) ? w : w.gsub('/', '\\') }.join(' ') # Split command by spaces, change / by \\ unless element is a some+thing://
|
|
60
|
-
cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D
|
|
61
|
-
cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D
|
|
62
|
-
logger.trace "executing locally: #{cmd}"
|
|
63
|
-
elapsed = Benchmark.realtime do
|
|
64
|
-
result = super(cmd)
|
|
65
|
-
end
|
|
66
|
-
else
|
|
67
|
-
logger.trace "executing locally: #{cmd}"
|
|
68
|
-
elapsed = Benchmark.realtime do
|
|
69
|
-
result = super
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
logger.trace "command finished in #{(elapsed * 1000).round}ms"
|
|
74
|
-
result
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
private
|
|
78
|
-
|
|
79
|
-
def logger
|
|
80
|
-
@logger ||= configuration.logger || Capistrano::Logger.new(:output => STDOUT)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# The revision to deploy. Must return a real revision identifier,
|
|
84
|
-
# and not a pseudo-id.
|
|
85
|
-
def revision
|
|
86
|
-
configuration[:real_revision]
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
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
|