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,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
|