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,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
|
|
@@ -1,299 +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
|
-
|
|
138
|
-
# Add an option for the branch name so :git_shallow_clone works with branches
|
|
139
|
-
args << "-b #{variable(:branch)}" unless variable(:branch).nil? || variable(:branch) == revision
|
|
140
|
-
args << "-o #{remote}" unless remote == 'origin'
|
|
141
|
-
if depth = variable(:git_shallow_clone)
|
|
142
|
-
args << "--depth #{depth}"
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
execute = []
|
|
146
|
-
execute << "#{git} clone #{verbose} #{args.join(' ')} #{variable(:repository)} #{destination}"
|
|
147
|
-
|
|
148
|
-
# checkout into a local branch rather than a detached HEAD
|
|
149
|
-
execute << "cd #{destination} && #{git} checkout #{verbose} -b deploy #{revision}"
|
|
150
|
-
|
|
151
|
-
if variable(:git_enable_submodules)
|
|
152
|
-
execute << "#{git} submodule #{verbose} init"
|
|
153
|
-
execute << "#{git} submodule #{verbose} sync"
|
|
154
|
-
if false == variable(:git_submodules_recursive)
|
|
155
|
-
execute << "#{git} submodule #{verbose} update --init"
|
|
156
|
-
else
|
|
157
|
-
execute << %Q(export GIT_RECURSIVE=$([ ! "`#{git} --version`" \\< "git version 1.6.5" ] && echo --recursive))
|
|
158
|
-
execute << "#{git} submodule #{verbose} update --init $GIT_RECURSIVE"
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
execute.compact.join(" && ").gsub(/\s+/, ' ')
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
# An expensive export. Performs a checkout as above, then
|
|
166
|
-
# removes the repo.
|
|
167
|
-
def export(revision, destination)
|
|
168
|
-
checkout(revision, destination) << " && rm -Rf #{destination}/.git"
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
# Merges the changes to 'head' since the last fetch, for remote_cache
|
|
172
|
-
# deployment strategy
|
|
173
|
-
def sync(revision, destination)
|
|
174
|
-
git = command
|
|
175
|
-
remote = origin
|
|
176
|
-
|
|
177
|
-
execute = []
|
|
178
|
-
execute << "cd #{destination}"
|
|
179
|
-
|
|
180
|
-
# Use git-config to setup a remote tracking branches. Could use
|
|
181
|
-
# git-remote but it complains when a remote of the same name already
|
|
182
|
-
# exists, git-config will just silenty overwrite the setting every
|
|
183
|
-
# time. This could cause wierd-ness in the remote cache if the url
|
|
184
|
-
# changes between calls, but as long as the repositories are all
|
|
185
|
-
# based from each other it should still work fine.
|
|
186
|
-
if remote != 'origin'
|
|
187
|
-
execute << "#{git} config remote.#{remote}.url #{variable(:repository)}"
|
|
188
|
-
execute << "#{git} config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/*"
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# since we're in a local branch already, just reset to specified revision rather than merge
|
|
192
|
-
execute << "#{git} fetch #{verbose} #{remote} && #{git} fetch --tags #{verbose} #{remote} && #{git} reset #{verbose} --hard #{revision}"
|
|
193
|
-
|
|
194
|
-
if variable(:git_enable_submodules)
|
|
195
|
-
execute << "#{git} submodule #{verbose} init"
|
|
196
|
-
execute << "#{git} submodule #{verbose} sync"
|
|
197
|
-
if false == variable(:git_submodules_recursive)
|
|
198
|
-
execute << "#{git} submodule #{verbose} update --init"
|
|
199
|
-
else
|
|
200
|
-
execute << %Q(export GIT_RECURSIVE=$([ ! "`#{git} --version`" \\< "git version 1.6.5" ] && echo --recursive))
|
|
201
|
-
execute << "#{git} submodule #{verbose} update --init $GIT_RECURSIVE"
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
# Make sure there's nothing else lying around in the repository (for
|
|
206
|
-
# example, a submodule that has subsequently been removed).
|
|
207
|
-
execute << "#{git} clean #{verbose} -d -x -f"
|
|
208
|
-
|
|
209
|
-
execute.join(" && ")
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# Returns a string of diffs between two revisions
|
|
213
|
-
def diff(from, to=nil)
|
|
214
|
-
return scm :diff, from unless to
|
|
215
|
-
scm :diff, "#{from}..#{to}"
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# Returns a log of changes between the two revisions (inclusive).
|
|
219
|
-
def log(from, to=nil)
|
|
220
|
-
scm :log, "#{from}..#{to}"
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
# Getting the actual commit id, in case we were passed a tag
|
|
224
|
-
# or partial sha or something - it will return the sha if you pass a sha, too
|
|
225
|
-
def query_revision(revision)
|
|
226
|
-
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\//
|
|
227
|
-
return revision if revision =~ /^[0-9a-f]{40}$/
|
|
228
|
-
command = scm('ls-remote', repository, revision)
|
|
229
|
-
result = yield(command)
|
|
230
|
-
revdata = result.split(/[\t\n]/)
|
|
231
|
-
newrev = nil
|
|
232
|
-
revdata.each_slice(2) do |refs|
|
|
233
|
-
rev, ref = *refs
|
|
234
|
-
if ref.sub(/refs\/.*?\//, '').strip == revision.to_s
|
|
235
|
-
newrev = rev
|
|
236
|
-
break
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
return newrev if newrev =~ /^[0-9a-f]{40}$/
|
|
240
|
-
|
|
241
|
-
# If sha is not found on remote, try expanding from local repository
|
|
242
|
-
command = scm('rev-parse --revs-only', origin + '/' + revision)
|
|
243
|
-
newrev = yield(command).to_s.strip
|
|
244
|
-
|
|
245
|
-
# fallback for expected legacy default functionality
|
|
246
|
-
unless newrev =~ /^[0-9a-f]{40}$/
|
|
247
|
-
command = scm('rev-parse --revs-only', revision)
|
|
248
|
-
newrev = yield(command).to_s.strip
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
raise "Unable to resolve revision for '#{revision}' on repository '#{repository}'." unless newrev =~ /^[0-9a-f]{40}$/
|
|
252
|
-
return newrev
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
def command
|
|
256
|
-
# For backwards compatibility with 1.x version of this module
|
|
257
|
-
variable(:git) || super
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
# Determines what the response should be for a particular bit of text
|
|
261
|
-
# from the SCM. Password prompts, connection requests, passphrases,
|
|
262
|
-
# etc. are handled here.
|
|
263
|
-
def handle_data(state, stream, text)
|
|
264
|
-
host = state[:channel][:host]
|
|
265
|
-
logger.info "[#{host} :: #{stream}] #{text}"
|
|
266
|
-
case text
|
|
267
|
-
when /\bpassword.*:/i
|
|
268
|
-
# git is prompting for a password
|
|
269
|
-
unless pass = variable(:scm_password)
|
|
270
|
-
pass = Capistrano::CLI.password_prompt
|
|
271
|
-
end
|
|
272
|
-
%("#{pass}"\n)
|
|
273
|
-
when %r{\(yes/no\)}
|
|
274
|
-
# git is asking whether or not to connect
|
|
275
|
-
"yes\n"
|
|
276
|
-
when /passphrase/i
|
|
277
|
-
# git is asking for the passphrase for the user's key
|
|
278
|
-
unless pass = variable(:scm_passphrase)
|
|
279
|
-
pass = Capistrano::CLI.password_prompt
|
|
280
|
-
end
|
|
281
|
-
%("#{pass}"\n)
|
|
282
|
-
when /accept \(t\)emporarily/
|
|
283
|
-
# git is asking whether to accept the certificate
|
|
284
|
-
"t\n"
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
private
|
|
289
|
-
|
|
290
|
-
# If verbose output is requested, return nil, otherwise return the
|
|
291
|
-
# command-line switch for "quiet" ("-q").
|
|
292
|
-
def verbose
|
|
293
|
-
variable(:scm_verbose) ? nil : "-q"
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
end
|
|
299
|
-
|
|
@@ -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,55 +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
|
-
#
|
|
22
|
-
# Dereference symbolic links. Copy files instead. Handy when you
|
|
23
|
-
# reference files and directory outside of your deployment root.
|
|
24
|
-
# set :copy_dereference_symlink, true
|
|
25
|
-
|
|
26
|
-
class None < Base
|
|
27
|
-
# No versioning, thus, no head. Returns the empty string.
|
|
28
|
-
def head
|
|
29
|
-
""
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Simply does a copy from the :repository directory to the
|
|
33
|
-
# :destination directory.
|
|
34
|
-
def checkout(revision, destination)
|
|
35
|
-
!Capistrano::Deploy::LocalDependency.on_windows? ? "cp -R#{configuration[:copy_dereference_symlink]?'L':''} #{repository} #{destination}" : "xcopy #{repository} \"#{destination}\" /S/I/Y/Q/E"
|
|
36
|
-
end
|
|
37
|
-
alias_method :export, :checkout
|
|
38
|
-
|
|
39
|
-
# No versioning, so this just returns the argument, with no
|
|
40
|
-
# modification.
|
|
41
|
-
def query_revision(revision)
|
|
42
|
-
revision
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# log: There's no log, so it just echos from and to.
|
|
46
|
-
|
|
47
|
-
def log(from="", to="")
|
|
48
|
-
"No SCM: #{from} - #{to}"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|