capistrano 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +4 -0
- data/CHANGELOG +53 -0
- data/Gemfile +1 -1
- data/README.mdown +17 -0
- data/capistrano.gemspec +0 -1
- data/lib/capistrano/configuration/servers.rb +4 -4
- data/lib/capistrano/recipes/deploy/scm/base.rb +8 -4
- data/lib/capistrano/recipes/deploy/scm/git.rb +13 -4
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +24 -15
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +6 -6
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +6 -7
- data/lib/capistrano/version.rb +1 -1
- data/test/command_test.rb +1 -0
- data/test/configuration/servers_test.rb +4 -4
- data/test/deploy/scm/git_test.rb +33 -6
- data/test/deploy/scm/perforce_test.rb +23 -0
- data/test/deploy/scm/subversion_test.rb +8 -0
- metadata +18 -17
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
@@ -1,3 +1,56 @@
|
|
1
|
+
## 2.9.0 / September 24 2011
|
2
|
+
|
3
|
+
A vairly heavy release, including some new features which most of you won't
|
4
|
+
need, but power users have contributed, this also marks the beginning of the
|
5
|
+
end of the 2.x series, more information will follow in due course, but with
|
6
|
+
the proliferation of Bundler, and better ways to do deployment, we will be
|
7
|
+
introducing heavier changes to Capistrano to keep the tool current.
|
8
|
+
|
9
|
+
**Please note, following some reported problems with the asset pipeline code
|
10
|
+
being not found, remember Capistrano needs to be in your Gemfile, and as such
|
11
|
+
needs to be run with Bundler, otherwise you risk loading a system-wide version
|
12
|
+
of Capistrano who's behaviour might be different from that specified in your
|
13
|
+
Gemfile. This is also good practice because much of the deploy logic resides
|
14
|
+
in the Gem, and you wouldn't want that to change without your knowledge. Rails
|
15
|
+
applications include Cap in the Gemfile anyway, you should follow this
|
16
|
+
convention.**
|
17
|
+
|
18
|
+
* find_servers() will no longer raise if there are no servers, this behaviour
|
19
|
+
can be modified by way of the `:on_no_matching_servers` option. Thanks to
|
20
|
+
`@ppgengler`.
|
21
|
+
|
22
|
+
* Short Git SHA1 fragments are now supported in commands such as `cap deploy
|
23
|
+
-s revision=d7e99f` thanks to `@ndbroadbent`.
|
24
|
+
|
25
|
+
* One can now specify individual SCM commands by setting
|
26
|
+
`:scm_arguments_<command_name>`. Thanks to `@alextk`.
|
27
|
+
|
28
|
+
* Travis CI build now passes thanks to @andrew, build tested against MRI
|
29
|
+
`1.8.7`. `1.9.2` and `REE`.
|
30
|
+
|
31
|
+
* Support for Perforce labels, I don't know much about this, but I believe
|
32
|
+
it's much like deploying a Git tag, thanks to `@ak47`.
|
33
|
+
|
34
|
+
* Git SCM now correctly adheres to the `:scm_verbose` setting. Thanks
|
35
|
+
`@dubek`.
|
36
|
+
|
37
|
+
* `set()` can now be used to set a `false` value, previously this was a no-op.
|
38
|
+
Thanks to `@nilbus`.
|
39
|
+
|
40
|
+
* Support for Git 1.6x submodules, The Git SCM strategy now queries Git on the
|
41
|
+
server-side to ensure it supports the `--recursive` flag, if it doesn't then
|
42
|
+
it will fall back to using the long-hand. Many thanks to all those involved in
|
43
|
+
the discussion surrounding this topic, and to `@nilbus` for a beautifully
|
44
|
+
clean solution which doesn't hold us back.
|
45
|
+
|
46
|
+
* When using `:cached_copy` with Subversion, use `svn switch` to for more
|
47
|
+
reliable switching of branches/etc. Thanks to `@iGEL` for the patch that we
|
48
|
+
accepted finally, and to `@richmeyers` who also submitted a patch and
|
49
|
+
contributed to the discssion.
|
50
|
+
|
51
|
+
Other cleanups and minor improvements to the code and tests were committed by yours truly
|
52
|
+
(@leehambley), @maxim, @ak47 and @andrew).
|
53
|
+
|
1
54
|
## 2.8.0 / August 3 2011
|
2
55
|
|
3
56
|
A short release, after the last. Announcing Rails 3.1 asset pipeline support.
|
data/Gemfile
CHANGED
data/README.mdown
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## Capistrano
|
2
2
|
|
3
|
+
[](http://travis-ci.org/capistrano/capistrano)
|
5
|
+
|
6
|
+
|
3
7
|
Capistrano is a utility and framework for executing commands in parallel on
|
4
8
|
multiple remote machines, via SSH. It uses a simple DSL (borrowed in part from
|
5
9
|
[Rake](http://rake.rubyforge.org/)) that allows you to define _tasks_, which may
|
@@ -54,6 +58,19 @@ By default, the script will look for a file called one of `capfile` or
|
|
54
58
|
"cap -h" to see all the available options and "cap -T" to see all the available
|
55
59
|
tasks.
|
56
60
|
|
61
|
+
## CONTRIBUTING:
|
62
|
+
|
63
|
+
* Fork Capistrano
|
64
|
+
* Create a topic branch - `git checkout -b my_branch`
|
65
|
+
* Rebase your branch so that all your changes are reflected in one
|
66
|
+
commit
|
67
|
+
* Push to your branch - `git push origin my_branch`
|
68
|
+
* Create a Pull Request from your branch, include as much documentation
|
69
|
+
as you can in the commit message/pull request, following these
|
70
|
+
[guidelies on writing a good commit message](http://spheredev.org/wiki/Git_for_the_lazy#Writing_good_commit_messages)
|
71
|
+
* That's it!
|
72
|
+
|
73
|
+
|
57
74
|
## LICENSE:
|
58
75
|
|
59
76
|
Permission is hereby granted, free of charge, to any person obtaining
|
data/capistrano.gemspec
CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/capistrano/capistrano"
|
12
12
|
s.summary = %q{Capistrano - Welcome to easy deployment with Ruby over SSH}
|
13
13
|
s.description = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.}
|
14
|
-
s.date = %q{2011-03-22}
|
15
14
|
s.files = `git ls-files`.split("\n")
|
16
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -54,13 +54,14 @@ module Capistrano
|
|
54
54
|
filter_server_list(hosts.uniq)
|
55
55
|
end
|
56
56
|
else
|
57
|
-
|
58
|
-
|
57
|
+
roles = role_list_from(ENV['ROLES'] || options[:roles] || self.roles.keys)
|
58
|
+
roles = roles & Array(options[:roles]) if preserve_roles && !options[:roles].nil?
|
59
59
|
|
60
60
|
only = options[:only] || {}
|
61
61
|
except = options[:except] || {}
|
62
62
|
|
63
|
-
|
63
|
+
# If we don't have a def for a role it means its bogus, skip it so higher level can handle
|
64
|
+
servers = roles.inject([]) { |list, role| list.concat(self.roles[role] || []) }
|
64
65
|
servers = servers.select { |server| only.all? { |key,value| server.options[key] == value } }
|
65
66
|
servers = servers.reject { |server| except.any? { |key,value| server.options[key] == value } }
|
66
67
|
|
@@ -103,7 +104,6 @@ module Capistrano
|
|
103
104
|
roles = build_list(roles)
|
104
105
|
roles.map do |role|
|
105
106
|
role = String === role ? role.strip.to_sym : role
|
106
|
-
raise ArgumentError, "unknown role `#{role}'" unless self.roles.key?(role)
|
107
107
|
role
|
108
108
|
end
|
109
109
|
end
|
@@ -163,9 +163,9 @@ module Capistrano
|
|
163
163
|
# consideration the current mode ("normal" vs. "local").
|
164
164
|
def variable(name, default = nil)
|
165
165
|
if local? && configuration.exists?("local_#{name}".to_sym)
|
166
|
-
return configuration["local_#{name}".to_sym]
|
166
|
+
return configuration["local_#{name}".to_sym].nil? ? default : configuration["local_#{name}".to_sym]
|
167
167
|
else
|
168
|
-
configuration[name]
|
168
|
+
configuration[name].nil? ? default : configuration[name]
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -186,8 +186,12 @@ module Capistrano
|
|
186
186
|
variable(:repository)
|
187
187
|
end
|
188
188
|
|
189
|
-
def arguments
|
190
|
-
variable(:scm_arguments)
|
189
|
+
def arguments(command = :all)
|
190
|
+
value = variable(:scm_arguments)
|
191
|
+
if value.is_a?(Hash)
|
192
|
+
value = value[command]
|
193
|
+
end
|
194
|
+
value
|
191
195
|
end
|
192
196
|
end
|
193
197
|
|
@@ -151,11 +151,12 @@ module Capistrano
|
|
151
151
|
if false == variable(:git_submodules_recursive)
|
152
152
|
execute << "#{git} submodule #{verbose} update --init"
|
153
153
|
else
|
154
|
-
execute << "
|
154
|
+
execute << %Q(export GIT_RECURSIVE=$([ ! "`#{git} --version`" \\< "git version 1.6.5" ] && echo --recursive))
|
155
|
+
execute << "#{git} submodule #{verbose} update --init $GIT_RECURSIVE"
|
155
156
|
end
|
156
157
|
end
|
157
158
|
|
158
|
-
execute.join(" && ").
|
159
|
+
execute.compact.join(" && ").gsub(/\s+/, ' ')
|
159
160
|
end
|
160
161
|
|
161
162
|
# An expensive export. Performs a checkout as above, then
|
@@ -194,7 +195,8 @@ module Capistrano
|
|
194
195
|
if false == variable(:git_submodules_recursive)
|
195
196
|
execute << "#{git} submodule #{verbose} update --init"
|
196
197
|
else
|
197
|
-
execute << "
|
198
|
+
execute << %Q(export GIT_RECURSIVE=$([ ! "`#{git} --version`" \\< "git version 1.6.5" ] && echo --recursive))
|
199
|
+
execute << "#{git} submodule #{verbose} update --init $GIT_RECURSIVE"
|
198
200
|
end
|
199
201
|
end
|
200
202
|
|
@@ -232,6 +234,12 @@ module Capistrano
|
|
232
234
|
break
|
233
235
|
end
|
234
236
|
end
|
237
|
+
return newrev if newrev =~ /^[0-9a-f]{40}$/
|
238
|
+
|
239
|
+
# If sha is not found on remote, try expanding from local repository
|
240
|
+
command = scm('rev-parse --revs-only', revision)
|
241
|
+
newrev = yield(command).to_s.strip
|
242
|
+
|
235
243
|
raise "Unable to resolve revision for '#{revision}' on repository '#{repository}'." unless newrev =~ /^[0-9a-f]{40}$/
|
236
244
|
return newrev
|
237
245
|
end
|
@@ -274,9 +282,10 @@ module Capistrano
|
|
274
282
|
# If verbose output is requested, return nil, otherwise return the
|
275
283
|
# command-line switch for "quiet" ("-q").
|
276
284
|
def verbose
|
277
|
-
variable(:scm_verbose
|
285
|
+
variable(:scm_verbose) ? nil : "-q"
|
278
286
|
end
|
279
287
|
end
|
280
288
|
end
|
281
289
|
end
|
282
290
|
end
|
291
|
+
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'capistrano/recipes/deploy/scm/base'
|
2
2
|
|
3
|
-
# Notes:
|
3
|
+
# Notes:
|
4
4
|
# no global verbose flag for scm_verbose
|
5
5
|
# sync, checkout and export are just sync in p4
|
6
|
-
#
|
6
|
+
#
|
7
7
|
module Capistrano
|
8
8
|
module Deploy
|
9
9
|
module SCM
|
@@ -27,7 +27,7 @@ module Capistrano
|
|
27
27
|
def checkout(revision, destination)
|
28
28
|
p4_sync(revision, destination, p4sync_flags)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
# Returns the command that will sync the given revision to the given
|
32
32
|
# destination directory. The perforce client has a fixed destination so
|
33
33
|
# the files must be copied from there to their intended resting place.
|
@@ -41,7 +41,7 @@ module Capistrano
|
|
41
41
|
def export(revision, destination)
|
42
42
|
p4_sync(revision, destination, p4sync_flags)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
# Returns the command that will do an "p4 diff2" for the two revisions.
|
46
46
|
def diff(from, to=head)
|
47
47
|
scm authentication, :diff2, "-u -db", "//#{p4client}/...#{rev_no(from)}", "//#{p4client}/...#{rev_no(to)}"
|
@@ -72,11 +72,11 @@ module Capistrano
|
|
72
72
|
raise Capistrano::Error, "scm_password (or p4passwd) is incorrect or unset"
|
73
73
|
when /Can.t create a new user.*/i
|
74
74
|
raise Capistrano::Error, "scm_username (or p4user) is incorrect or unset"
|
75
|
-
when /Perforce client error\:/i
|
75
|
+
when /Perforce client error\:/i
|
76
76
|
raise Capistrano::Error, "p4port is incorrect or unset"
|
77
77
|
when /Client \'[\w\-\_\.]+\' unknown.*/i
|
78
78
|
raise Capistrano::Error, "p4client is incorrect or unset"
|
79
|
-
end
|
79
|
+
end
|
80
80
|
end
|
81
81
|
|
82
82
|
private
|
@@ -90,11 +90,11 @@ module Capistrano
|
|
90
90
|
end
|
91
91
|
|
92
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.
|
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
96
|
def p4_sync(revision, destination, options="")
|
97
|
-
scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}"
|
97
|
+
scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}"
|
98
98
|
end
|
99
99
|
|
100
100
|
def p4client
|
@@ -108,7 +108,7 @@ module Capistrano
|
|
108
108
|
def p4user
|
109
109
|
variable(:p4user) || variable(:scm_username)
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def p4passwd
|
113
113
|
variable(:p4passwd) || variable(:scm_password)
|
114
114
|
end
|
@@ -120,16 +120,25 @@ module Capistrano
|
|
120
120
|
def p4client_root
|
121
121
|
variable(:p4client_root) || "`#{command} #{authentication} client -o | grep ^Root | cut -f2`"
|
122
122
|
end
|
123
|
-
|
124
|
-
def rev_no(revision)
|
123
|
+
|
124
|
+
def rev_no(revision)
|
125
|
+
if variable(:p4_label)
|
126
|
+
p4_label = if variable(:p4_label) =~ /\A@/
|
127
|
+
variable(:p4_label)
|
128
|
+
else
|
129
|
+
"@#{variable(:p4_label)}"
|
130
|
+
end
|
131
|
+
return p4_label
|
132
|
+
end
|
133
|
+
|
125
134
|
case revision.to_s
|
126
135
|
when "head"
|
127
136
|
"#head"
|
128
|
-
when /^\d+/
|
137
|
+
when /^\d+/
|
129
138
|
"@#{revision}"
|
130
139
|
else
|
131
140
|
revision
|
132
|
-
end
|
141
|
+
end
|
133
142
|
end
|
134
143
|
end
|
135
144
|
|
@@ -21,29 +21,29 @@ module Capistrano
|
|
21
21
|
# Returns the command that will check out the given revision to the
|
22
22
|
# given destination.
|
23
23
|
def checkout(revision, destination)
|
24
|
-
scm :checkout, arguments, verbose, authentication, "-r#{revision}", repository, destination
|
24
|
+
scm :checkout, arguments, arguments(:checkout), verbose, authentication, "-r#{revision}", repository, destination
|
25
25
|
end
|
26
26
|
|
27
27
|
# Returns the command that will do an "svn update" to the given
|
28
28
|
# revision, for the working copy at the given destination.
|
29
29
|
def sync(revision, destination)
|
30
|
-
scm :
|
30
|
+
scm :switch, arguments, verbose, authentication, "-r#{revision}", repository, destination
|
31
31
|
end
|
32
32
|
|
33
33
|
# Returns the command that will do an "svn export" of the given revision
|
34
34
|
# to the given destination.
|
35
35
|
def export(revision, destination)
|
36
|
-
scm :export, arguments, verbose, authentication, "-r#{revision}", repository, destination
|
36
|
+
scm :export, arguments, arguments(:export), verbose, authentication, "-r#{revision}", repository, destination
|
37
37
|
end
|
38
38
|
|
39
39
|
# Returns the command that will do an "svn diff" for the two revisions.
|
40
40
|
def diff(from, to=nil)
|
41
|
-
scm :diff, repository, authentication, "-r#{from}:#{to || head}"
|
41
|
+
scm :diff, repository, arguments(:diff), authentication, "-r#{from}:#{to || head}"
|
42
42
|
end
|
43
43
|
|
44
44
|
# Returns an "svn log" command for the two revisions.
|
45
45
|
def log(from, to=nil)
|
46
|
-
scm :log, repository, authentication, "-r#{from}:#{to || head}"
|
46
|
+
scm :log, repository, arguments(:log), authentication, "-r#{from}:#{to || head}"
|
47
47
|
end
|
48
48
|
|
49
49
|
# Attempts to translate the given revision identifier to a "real"
|
@@ -52,7 +52,7 @@ module Capistrano
|
|
52
52
|
# executed (svn info), and will extract the revision from the response.
|
53
53
|
def query_revision(revision)
|
54
54
|
return revision if revision =~ /^\d+$/
|
55
|
-
command = scm(:info, arguments, repository, authentication, "-r#{revision}")
|
55
|
+
command = scm(:info, arguments, arguments(:info), repository, authentication, "-r#{revision}")
|
56
56
|
result = yield(command)
|
57
57
|
yaml = YAML.load(result)
|
58
58
|
raise "tried to run `#{command}' and got unexpected result #{result.inspect}" unless Hash === yaml
|
@@ -86,13 +86,12 @@ module Capistrano
|
|
86
86
|
|
87
87
|
if copy_exclude.any?
|
88
88
|
logger.debug "processing exclusions..."
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
89
|
+
|
90
|
+
copy_exclude.each do |pattern|
|
91
|
+
delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH)
|
92
|
+
# avoid the /.. trap that deletes the parent directories
|
93
|
+
delete_list.delete_if { |dir| dir =~ /\/\.\.$/ }
|
94
|
+
FileUtils.rm_rf(delete_list.compact)
|
96
95
|
end
|
97
96
|
end
|
98
97
|
end
|
data/lib/capistrano/version.rb
CHANGED
data/test/command_test.rb
CHANGED
@@ -205,6 +205,7 @@ class CommandTest < Test::Unit::TestCase
|
|
205
205
|
new_channel = Proc.new do |times|
|
206
206
|
ch = mock("channel")
|
207
207
|
returns = [false] * (times-1)
|
208
|
+
ch.stubs(:to_ary)
|
208
209
|
ch.stubs(:[]).with(:closed).returns(*(returns + [true]))
|
209
210
|
ch.expects(:[]).with(:status).returns(0)
|
210
211
|
ch
|
@@ -39,11 +39,11 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
|
39
39
|
assert_equal %w(web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
# NOTE Rather than throw an error, as it used to, we return an
|
43
|
+
# empty array so that if a task is okay with a missing role it can continue on
|
44
|
+
def test_task_with_unknown_role_should_return_empty_array
|
43
45
|
task = new_task(:testing, @config, :roles => :bogus)
|
44
|
-
|
45
|
-
@config.find_servers_for_task(task)
|
46
|
-
end
|
46
|
+
assert_equal [], @config.find_servers_for_task(task)
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_task_with_hosts_option_should_apply_only_to_those_hosts
|
data/test/deploy/scm/git_test.rb
CHANGED
@@ -15,7 +15,7 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
def test_head
|
17
17
|
assert_equal "HEAD", @source.head
|
18
|
-
|
18
|
+
|
19
19
|
# With :branch
|
20
20
|
@config[:branch] = "master"
|
21
21
|
assert_equal "master", @source.head
|
@@ -40,14 +40,31 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
40
40
|
|
41
41
|
# with submodules
|
42
42
|
@config[:git_enable_submodules] = true
|
43
|
-
assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && #{git} submodule -q update --init
|
43
|
+
assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && export GIT_RECURSIVE=$([ ! \"`#{git} --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && #{git} submodule -q update --init $GIT_RECURSIVE", @source.checkout(rev, dest).gsub(/\s+/, ' ')
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def test_checkout_submodules_without_recursive
|
47
|
+
@config[:repository] = "git@somehost.com:project.git"
|
48
|
+
dest = "/var/www"
|
49
|
+
rev = 'c2d9e79'
|
50
|
+
@config[:git_enable_submodules] = true
|
51
|
+
@config[:git_submodules_recursive] = false
|
52
|
+
assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update --init", @source.checkout(rev, dest).gsub(/\s+/, ' ')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_checkout_with_verbose_should_not_use_q_switch
|
47
56
|
@config[:repository] = "git@somehost.com:project.git"
|
48
57
|
@config[:scm_verbose] = true
|
49
58
|
dest = "/var/www"
|
50
59
|
rev = 'c2d9e79'
|
60
|
+
assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_checkout_with_verbose_off_should_use_q_switch
|
64
|
+
@config[:repository] = "git@somehost.com:project.git"
|
65
|
+
@config[:scm_verbose] = false
|
66
|
+
dest = "/var/www"
|
67
|
+
rev = 'c2d9e79'
|
51
68
|
assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
|
52
69
|
end
|
53
70
|
|
@@ -61,7 +78,7 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
61
78
|
assert_equal "git log master..branch", @source.log('master', 'branch')
|
62
79
|
end
|
63
80
|
|
64
|
-
def
|
81
|
+
def test_query_revision_from_remote
|
65
82
|
revision = @source.query_revision('HEAD') do |o|
|
66
83
|
assert_equal "git ls-remote . HEAD", o
|
67
84
|
"d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD"
|
@@ -69,6 +86,15 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
69
86
|
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
|
70
87
|
end
|
71
88
|
|
89
|
+
def test_query_revision_falls_back_to_local
|
90
|
+
revision = @source.query_revision('d11006') do |o|
|
91
|
+
return nil if o == "git ls-remote . d11006"
|
92
|
+
assert_equal "git rev-parse --revs-only d11006", o
|
93
|
+
"d11006102c07c94e5d54dd0ee63dca825c93ed61"
|
94
|
+
end
|
95
|
+
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
|
96
|
+
end
|
97
|
+
|
72
98
|
def test_query_revision_has_whitespace
|
73
99
|
revision = @source.query_revision('HEAD') do |o|
|
74
100
|
assert_equal "git ls-remote . HEAD", o
|
@@ -101,7 +127,7 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
101
127
|
|
102
128
|
# with submodules
|
103
129
|
@config[:git_enable_submodules] = true
|
104
|
-
assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} fetch --tags -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && 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 && #{git} submodule -q sync && #{git} submodule -q update --init
|
130
|
+
assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} fetch --tags -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && 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 && #{git} submodule -q sync && export GIT_RECURSIVE=$([ ! \"`#{git} --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && #{git} submodule -q update --init $GIT_RECURSIVE && #{git} clean -q -d -x -f", @source.sync(rev, dest)
|
105
131
|
end
|
106
132
|
|
107
133
|
def test_sync_with_remote
|
@@ -138,7 +164,7 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
138
164
|
@config[:git_enable_submodules] = true
|
139
165
|
dest = "/var/www"
|
140
166
|
rev = 'c2d9e79'
|
141
|
-
assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update --init
|
167
|
+
assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && git submodule -q update --init $GIT_RECURSIVE", @source.checkout(rev, dest)
|
142
168
|
end
|
143
169
|
|
144
170
|
# Tests from base_test.rb, makin' sure we didn't break anything up there!
|
@@ -182,3 +208,4 @@ class DeploySCMGitTest < Test::Unit::TestCase
|
|
182
208
|
assert_equal "/foo/bar/git", @source.command
|
183
209
|
end
|
184
210
|
end
|
211
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/scm/perforce'
|
3
|
+
|
4
|
+
class DeploySCMPerforceTest < Test::Unit::TestCase
|
5
|
+
class TestSCM < Capistrano::Deploy::SCM::Perforce
|
6
|
+
default_command "perforce"
|
7
|
+
end
|
8
|
+
def setup
|
9
|
+
@config = { :repository => "." }
|
10
|
+
@source = TestSCM.new(@config)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_p4_label
|
14
|
+
@config[:p4_label] = "some_p4_label"
|
15
|
+
assert_equal "@some_p4_label", @source.send(:rev_no, 'foo')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_p4_label_with_symbol
|
19
|
+
@config[:p4_label] = "@some_p4_label"
|
20
|
+
assert_equal "@some_p4_label", @source.send(:rev_no, 'foo')
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -29,4 +29,12 @@ Last Changed Date: 2009-03-11 11:04:25 -0700 (Wed, 11 Mar 2009)
|
|
29
29
|
end
|
30
30
|
assert_equal 2095, revision
|
31
31
|
end
|
32
|
+
|
33
|
+
def test_sync
|
34
|
+
@config[:repository] = "http://svn.github.com/capistrano/capistrano.git"
|
35
|
+
rev = '602'
|
36
|
+
dest = "/var/www"
|
37
|
+
assert_equal "svn switch -q -r602 http://svn.github.com/capistrano/capistrano.git /var/www", @source.sync(rev, dest)
|
38
|
+
end
|
39
|
+
|
32
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-09-24 00:00:00.000000000Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: highline
|
18
|
-
requirement: &
|
17
|
+
requirement: &70363620892360 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
21
20
|
- - ! '>='
|
@@ -23,10 +22,10 @@ dependencies:
|
|
23
22
|
version: '0'
|
24
23
|
type: :runtime
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
25
|
+
version_requirements: *70363620892360
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: net-ssh
|
29
|
-
requirement: &
|
28
|
+
requirement: &70363620908220 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
32
31
|
- - ! '>='
|
@@ -34,10 +33,10 @@ dependencies:
|
|
34
33
|
version: 2.0.14
|
35
34
|
type: :runtime
|
36
35
|
prerelease: false
|
37
|
-
version_requirements: *
|
36
|
+
version_requirements: *70363620908220
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
38
|
name: net-sftp
|
40
|
-
requirement: &
|
39
|
+
requirement: &70363620907740 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
42
|
- - ! '>='
|
@@ -45,10 +44,10 @@ dependencies:
|
|
45
44
|
version: 2.0.0
|
46
45
|
type: :runtime
|
47
46
|
prerelease: false
|
48
|
-
version_requirements: *
|
47
|
+
version_requirements: *70363620907740
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
49
|
name: net-scp
|
51
|
-
requirement: &
|
50
|
+
requirement: &70363620907260 !ruby/object:Gem::Requirement
|
52
51
|
none: false
|
53
52
|
requirements:
|
54
53
|
- - ! '>='
|
@@ -56,10 +55,10 @@ dependencies:
|
|
56
55
|
version: 1.0.0
|
57
56
|
type: :runtime
|
58
57
|
prerelease: false
|
59
|
-
version_requirements: *
|
58
|
+
version_requirements: *70363620907260
|
60
59
|
- !ruby/object:Gem::Dependency
|
61
60
|
name: net-ssh-gateway
|
62
|
-
requirement: &
|
61
|
+
requirement: &70363620906780 !ruby/object:Gem::Requirement
|
63
62
|
none: false
|
64
63
|
requirements:
|
65
64
|
- - ! '>='
|
@@ -67,10 +66,10 @@ dependencies:
|
|
67
66
|
version: 1.1.0
|
68
67
|
type: :runtime
|
69
68
|
prerelease: false
|
70
|
-
version_requirements: *
|
69
|
+
version_requirements: *70363620906780
|
71
70
|
- !ruby/object:Gem::Dependency
|
72
71
|
name: mocha
|
73
|
-
requirement: &
|
72
|
+
requirement: &70363620906300 !ruby/object:Gem::Requirement
|
74
73
|
none: false
|
75
74
|
requirements:
|
76
75
|
- - ! '>='
|
@@ -78,7 +77,7 @@ dependencies:
|
|
78
77
|
version: '0'
|
79
78
|
type: :development
|
80
79
|
prerelease: false
|
81
|
-
version_requirements: *
|
80
|
+
version_requirements: *70363620906300
|
82
81
|
description: Capistrano is a utility and framework for executing commands in parallel
|
83
82
|
on multiple remote machines, via SSH.
|
84
83
|
email:
|
@@ -93,6 +92,7 @@ extra_rdoc_files:
|
|
93
92
|
files:
|
94
93
|
- .gitignore
|
95
94
|
- .rvmrc
|
95
|
+
- .travis.yml
|
96
96
|
- CHANGELOG
|
97
97
|
- Gemfile
|
98
98
|
- README.mdown
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- test/deploy/scm/git_test.rb
|
189
189
|
- test/deploy/scm/mercurial_test.rb
|
190
190
|
- test/deploy/scm/none_test.rb
|
191
|
+
- test/deploy/scm/perforce_test.rb
|
191
192
|
- test/deploy/scm/subversion_test.rb
|
192
193
|
- test/deploy/strategy/copy_test.rb
|
193
194
|
- test/extensions_test.rb
|
@@ -203,7 +204,6 @@ files:
|
|
203
204
|
- test/task_definition_test.rb
|
204
205
|
- test/transfer_test.rb
|
205
206
|
- test/utils.rb
|
206
|
-
has_rdoc: true
|
207
207
|
homepage: http://github.com/capistrano/capistrano
|
208
208
|
licenses: []
|
209
209
|
post_install_message:
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
|
-
rubygems_version: 1.
|
227
|
+
rubygems_version: 1.8.7
|
228
228
|
signing_key:
|
229
229
|
specification_version: 3
|
230
230
|
summary: Capistrano - Welcome to easy deployment with Ruby over SSH
|
@@ -256,6 +256,7 @@ test_files:
|
|
256
256
|
- test/deploy/scm/git_test.rb
|
257
257
|
- test/deploy/scm/mercurial_test.rb
|
258
258
|
- test/deploy/scm/none_test.rb
|
259
|
+
- test/deploy/scm/perforce_test.rb
|
259
260
|
- test/deploy/scm/subversion_test.rb
|
260
261
|
- test/deploy/strategy/copy_test.rb
|
261
262
|
- test/extensions_test.rb
|