capistrano 3.1.0 → 3.2.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +25 -2
- data/CONTRIBUTING.md +3 -1
- data/README.md +57 -13
- data/features/configuration.feature +13 -0
- data/features/step_definitions/assertions.rb +4 -0
- data/features/step_definitions/cap_commands.rb +1 -1
- data/features/step_definitions/setup.rb +8 -4
- data/lib/capistrano/application.rb +5 -8
- data/lib/capistrano/configuration.rb +6 -4
- data/lib/capistrano/configuration/server.rb +5 -1
- data/lib/capistrano/defaults.rb +1 -1
- data/lib/capistrano/dsl.rb +0 -11
- data/lib/capistrano/dsl/paths.rb +1 -0
- data/lib/capistrano/dsl/stages.rb +0 -3
- data/lib/capistrano/dsl/task_enhancements.rb +4 -2
- data/lib/capistrano/git.rb +5 -1
- data/lib/capistrano/hg.rb +4 -0
- data/lib/capistrano/i18n.rb +1 -0
- data/lib/capistrano/scm.rb +16 -4
- data/lib/capistrano/svn.rb +38 -0
- data/lib/capistrano/tasks/deploy.rake +25 -6
- data/lib/capistrano/tasks/git.rake +12 -2
- data/lib/capistrano/tasks/hg.rake +9 -0
- data/lib/capistrano/tasks/svn.rake +52 -0
- data/lib/capistrano/templates/Capfile +1 -1
- data/lib/capistrano/templates/deploy.rb.erb +1 -1
- data/lib/capistrano/templates/stage.rb.erb +20 -14
- data/lib/capistrano/version.rb +1 -1
- data/spec/integration/dsl_spec.rb +7 -5
- data/spec/lib/capistrano/configuration/server_spec.rb +9 -9
- data/spec/lib/capistrano/configuration/servers_spec.rb +12 -6
- data/spec/lib/capistrano/configuration_spec.rb +42 -0
- data/spec/lib/capistrano/git_spec.rb +1 -1
- data/spec/lib/capistrano/svn_spec.rb +69 -0
- data/spec/support/tasks/{database.cap → database.rake} +0 -0
- data/spec/support/tasks/{fail.cap → fail.rake} +0 -0
- data/spec/support/tasks/{failed.cap → failed.rake} +0 -0
- data/spec/support/test_app.rb +9 -2
- metadata +12 -9
- data/capistrano-public_cert.pem +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59f8fb6442e27e32704d86292e1e22a6c67daa61
|
|
4
|
+
data.tar.gz: 7ecf7b387a1c3cbf2c0bc2685e3ec6b6a1336d9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a03a957b09b8b2c28f29e8f3bb81f099fdaca0f4cec6d1741591a82a24617e36416c3e8aa2ba3ff29ae6b9cb612162d8e13bb32bfb04f816fe86736aed5ca12
|
|
7
|
+
data.tar.gz: 383b341deed499908407ade22a77432bef14797a70247c5e1fc48b19103cd20e3fe4ba5b23256b5b8155ae754b4e5626cd20b2a6aa09a4bab98faffa7358872a
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Reverse Chronological Order:
|
|
4
4
|
|
|
5
|
+
## master
|
|
6
|
+
|
|
7
|
+
https://github.com/capistrano/capistrano/compare/v3.2.0...HEAD
|
|
8
|
+
|
|
9
|
+
## `3.2.0``
|
|
10
|
+
|
|
11
|
+
The changelog entries here are incomplete, because many authors choose not to
|
|
12
|
+
be credited for their work, check the tag comparison link for Github.
|
|
13
|
+
|
|
14
|
+
https://github.com/capistrano/capistrano/compare/v3.1.0...v3.2.0
|
|
15
|
+
|
|
16
|
+
* Minor changes:
|
|
17
|
+
* Added `keys` method to Server properties to allow introspection of automatically added
|
|
18
|
+
properties.
|
|
19
|
+
* Compatibility with Rake 10.2.0 - `ensure_task` is now added to `@top_level_tasks` as a string. (@dmarkow)
|
|
20
|
+
* Amended the git check command, "ls-remote", to use "-h", limiting the list to refs/heads
|
|
21
|
+
|
|
5
22
|
## `3.1.0`
|
|
6
23
|
|
|
24
|
+
https://github.com/capistrano/capistrano/compare/v3.0.1...v3.1.0
|
|
25
|
+
|
|
7
26
|
Breaking changes:
|
|
8
27
|
|
|
9
28
|
* `deploy:restart` task **is no longer run by default**.
|
|
@@ -20,7 +39,7 @@ Breaking changes:
|
|
|
20
39
|
* Config location can now be changed with `deploy_config_path` and `stage_config_path` options (@seenmyfate)
|
|
21
40
|
* `no_release` option is now available (@seenmyfate)
|
|
22
41
|
* Raise an error if developer tries to define `:all` role, which is reserved (@kirs)
|
|
23
|
-
* `deploy:
|
|
42
|
+
* `deploy:failed` hook was added to add some custom behaviour on failed deploy (@seenmyfate)
|
|
24
43
|
* Correctly infer namespace in task enhancements (@seenmyfate)
|
|
25
44
|
* Add SHA to revision log (@blackxored)
|
|
26
45
|
* Allow configuration of multiple servers with same hostname but different ports (@rsslldnphy)
|
|
@@ -37,12 +56,16 @@ Big thanks to @Kriechi for his help.
|
|
|
37
56
|
|
|
38
57
|
## `3.0.1`
|
|
39
58
|
|
|
59
|
+
https://github.com/capistrano/capistrano/compare/v3.0.0...v3.0.1
|
|
60
|
+
|
|
40
61
|
* `capify` not listed as executable (@leehambley)
|
|
41
62
|
* Confirm license as MIT (@leehambley)
|
|
42
63
|
* Move the git ssh helper to application path (@mpapis)
|
|
43
64
|
|
|
44
65
|
## `3.0.0`
|
|
45
66
|
|
|
67
|
+
https://github.com/capistrano/capistrano/compare/2.15.5...v3.0.0
|
|
68
|
+
|
|
46
69
|
If you are coming here to wonder why your Capfile doesn't work anymore, please
|
|
47
70
|
vendor lock your Capistrano at 2.x, whichever version was working for you
|
|
48
71
|
until today.
|
|
@@ -79,7 +102,7 @@ extension the trusted contributors and IRC regulars) were able to test for.
|
|
|
79
102
|
There's a more extensive post about my failure to be able to keep up with the
|
|
80
103
|
demands of maintaining v2 whilst trying to build something which is appropriate
|
|
81
104
|
for the current landscape. If you are affected by the unsupported 2 branch,
|
|
82
|
-
please contact me (Lee Hambley) to
|
|
105
|
+
please contact me (Lee Hambley) to discuss how my company can help support you.
|
|
83
106
|
Otherwise, please try v3, we're sure you'll like it, and the code is designed
|
|
84
107
|
to be so simple that anyone can work on it.
|
|
85
108
|
|
data/CONTRIBUTING.md
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
or improvements to the code.**
|
|
5
5
|
|
|
6
6
|
If you have a user support query, or you suspect that you might just be holding
|
|
7
|
-
it wrong, drop us a line at [the mailing list]() or
|
|
7
|
+
it wrong, drop us a line at [the mailing list](https://groups.google.com/forum/#!forum/capistrano), [StackOverflow](http://stackoverflow.com/questions/tagged/capistrano) or at [CodersClan](http://codersclan.net/?repo_id=325&source=contributing). The
|
|
8
8
|
mailing list is moderated to cut down on spam, so please be patient, if you use
|
|
9
9
|
StackOverflow, make sure to tag your post with "Capistrano". (Not forgetting
|
|
10
10
|
any other tags which might relate, rvm, rbenv, Ubuntu, etc.)
|
|
11
11
|
|
|
12
|
+
If you have an urgent problem you can use [CodersClan](http://codersclan.net/?repo_id=325&source=contributing) to solve your problem quickly. CodersClan has a community of Capistrano experts dedicated to solve code problems for bounties.
|
|
13
|
+
|
|
12
14
|
Wherever you post please be sure to include the version of Capistrano you are
|
|
13
15
|
using, which versions of any plugins (*capistrano-rvm*, *capistrano-bundler*,
|
|
14
16
|
etc.). Proper logs are vital, if you need to redact them, go ahead, but be
|
data/README.md
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
# Capistrano [](https://travis-ci.org/capistrano/capistrano) [](https://codeclimate.com/github/capistrano/capistrano)
|
|
1
|
+
# Capistrano [](https://travis-ci.org/capistrano/capistrano) [](https://codeclimate.com/github/capistrano/capistrano) <a href="http://codersclan.net/?repo_id=325&source=small"><img src="http://www.codersclan.net/gs_button/?repo_id=325&size=small" width="69"></a>
|
|
2
2
|
|
|
3
3
|
## Requirements
|
|
4
4
|
|
|
5
5
|
* Ruby >= 1.9 (JRuby and C-Ruby/YARV are supported)
|
|
6
6
|
|
|
7
|
+
## Support
|
|
8
|
+
|
|
9
|
+
Need help with getting Capistrano up and running? Got a code problem you want to get solved quickly?
|
|
10
|
+
|
|
11
|
+
Get <a href="http://codersclan.net/?repo_id=325&source=link">Capistrano support on CodersClan.</a>
|
|
12
|
+
|
|
13
|
+
<a href="http://codersclan.net/?repo_id=325&source=big"><img src="http://www.codersclan.net/gs_button/?repo_id=325" width="200"></a>
|
|
14
|
+
|
|
7
15
|
## Installation
|
|
8
16
|
|
|
9
17
|
Add this line to your application's Gemfile:
|
|
10
18
|
|
|
11
19
|
``` ruby
|
|
12
|
-
gem 'capistrano', '~> 3.0
|
|
20
|
+
gem 'capistrano', '~> 3.1.0'
|
|
13
21
|
```
|
|
14
22
|
|
|
15
23
|
And then execute:
|
|
@@ -65,11 +73,19 @@ server 'example.org', roles: [:db, :workers]
|
|
|
65
73
|
desc "Report Uptimes"
|
|
66
74
|
task :uptime do
|
|
67
75
|
on roles(:all) do |host|
|
|
76
|
+
execute :any_command, "with args", :here, "and here"
|
|
68
77
|
info "Host #{host} (#{host.roles.to_a.join(', ')}):\t#{capture(:uptime)}"
|
|
69
78
|
end
|
|
70
79
|
end
|
|
71
80
|
```
|
|
72
81
|
|
|
82
|
+
**Note**:
|
|
83
|
+
|
|
84
|
+
**tl;dr**: `execute(:bundle, :install)` and `execute('bundle install')` don't behave identically!
|
|
85
|
+
|
|
86
|
+
`execute()` has a subtle behaviour. When calling `within './directory' { execute(:bundle, :install) }` for example, the first argument to `execute()` is a *Stringish* with ***no whitespace***. This allows the command to pass through the [SSHKit::CommandMap](https://github.com/capistrano/sshkit#the-command-map) which enables a number of powerful features.
|
|
87
|
+
|
|
88
|
+
When the first argument to `execute()` contains whitespace, for example `within './directory' { execute('bundle install') }` (or when using a heredoc), neither Capistrano, nor SSHKit can reliably predict how it should be shell escaped, and thus cannot perform any context, or command mapping, that means that the `within(){}` (as well as `with()`, `as()`, etc) have no effect. There have been a few attempts to resolve this, but we don't consider it a bug although we acknowledge that it might be a little counter intuitive.
|
|
73
89
|
## Before / After
|
|
74
90
|
|
|
75
91
|
Where calling on the same task name, executed in order of inclusion
|
|
@@ -110,12 +126,14 @@ end
|
|
|
110
126
|
The final way to call out to other tasks is to simply `invoke()` them:
|
|
111
127
|
|
|
112
128
|
``` ruby
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
namespace :example do
|
|
130
|
+
task :one do
|
|
131
|
+
on roles(:all) { info "One" }
|
|
132
|
+
end
|
|
133
|
+
task :two do
|
|
134
|
+
invoke "example:one"
|
|
135
|
+
on roles(:all) { info "Two" }
|
|
136
|
+
end
|
|
119
137
|
end
|
|
120
138
|
```
|
|
121
139
|
|
|
@@ -136,12 +154,21 @@ end
|
|
|
136
154
|
Perfect, who needs telephones.
|
|
137
155
|
|
|
138
156
|
|
|
157
|
+
## Using password authentication
|
|
158
|
+
|
|
159
|
+
Password authentication can be done via `set` and `ask` in your deploy environment file (e.g.: config/environments/production.rb)
|
|
160
|
+
|
|
161
|
+
```ruby
|
|
162
|
+
set :password, ask('Server password:', nil)
|
|
163
|
+
server 'server.domain.com', user: 'ssh_user_name', port: 22, password: fetch(:password), roles: %w{web app db}
|
|
164
|
+
```
|
|
165
|
+
|
|
139
166
|
## Running local tasks
|
|
140
167
|
|
|
141
168
|
Local tasks can be run by replacing `on` with `run_locally`
|
|
142
169
|
|
|
143
170
|
``` ruby
|
|
144
|
-
desc
|
|
171
|
+
desc 'Notify service of deployment'
|
|
145
172
|
task :notify do
|
|
146
173
|
run_locally do
|
|
147
174
|
with rails_env: :development do
|
|
@@ -151,6 +178,21 @@ task :notify do
|
|
|
151
178
|
end
|
|
152
179
|
```
|
|
153
180
|
|
|
181
|
+
Of course, you can always just use standard ruby syntax to run things locally
|
|
182
|
+
``` ruby
|
|
183
|
+
desc 'Notify service of deployment'
|
|
184
|
+
task :notify do
|
|
185
|
+
%x('RAILS_ENV=development bundle exec rake "service:notify"')
|
|
186
|
+
end
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Alternatively you could use the rake syntax
|
|
190
|
+
``` ruby
|
|
191
|
+
desc "Notify service of deployment"
|
|
192
|
+
task :notify do
|
|
193
|
+
sh 'RAILS_ENV=development bundle exec rake "service:notify"'
|
|
194
|
+
end
|
|
195
|
+
```
|
|
154
196
|
## Console
|
|
155
197
|
|
|
156
198
|
**Note:** Here be dragons. The console is very immature, but it's much more
|
|
@@ -186,7 +228,7 @@ DEBUG [9ce34809] leehambley pts/0 2013-06-13 17:11 (port-11262.pppoe.wtn
|
|
|
186
228
|
|
|
187
229
|
There is a configuration option which asks the backend driver to ask the remote host
|
|
188
230
|
to assign the connection a *pty*. A *pty* is a pseudo-terminal, which in effect means
|
|
189
|
-
*tell the backend that this is an
|
|
231
|
+
*tell the backend that this is an __interactive__ session*. This is normally a bad idea.
|
|
190
232
|
|
|
191
233
|
Most of the differences are best explained by [this page](https://github.com/sstephenson/rbenv/wiki/Unix-shell-initialization) from the author of *rbenv*.
|
|
192
234
|
|
|
@@ -209,7 +251,9 @@ The following variables are settable:
|
|
|
209
251
|
|
|
210
252
|
| Variable Name | Description | Notes |
|
|
211
253
|
|:---------------------:|----------------------------------------------------------------------|-----------------------------------------------------------------|
|
|
212
|
-
| `:repo_url` | The URL of your
|
|
254
|
+
| `:repo_url` | The URL of your scm repository (git, hg, svn) | file://, https://, ssh://, or svn+ssh:// are all supported |
|
|
255
|
+
| `:branch` | The branch you wish to deploy | This only has meaning for git and hg repos, to specify the branch of an svn repo, set `:repo_url` to the branch location. |
|
|
256
|
+
| `:scm` | The source control system used | `:git`, `:hg`, `:svn` are currently supported |
|
|
213
257
|
| `:tmp_dir` | The (optional) temp directory that will be used (default: /tmp) | if you have a shared web host, this setting may need to be set (i.e. /home/user/tmp/capistrano). |
|
|
214
258
|
|
|
215
259
|
__Support removed__ for following variables:
|
|
@@ -225,9 +269,9 @@ connections behind the scenes in Capistrano. Depending on how deep you dig, you
|
|
|
225
269
|
might run into interfaces that come directly from SSHKit (the configuration is
|
|
226
270
|
a good example).
|
|
227
271
|
|
|
228
|
-
##
|
|
272
|
+
## License
|
|
229
273
|
|
|
230
|
-
|
|
274
|
+
MIT License (MIT)
|
|
231
275
|
|
|
232
276
|
Copyright (c) 2012-2013 Tom Clements, Lee Hambley
|
|
233
277
|
|
|
@@ -13,3 +13,16 @@ Feature: The path to the configuration can be changed, removing the need to
|
|
|
13
13
|
But the configuration is in a custom location
|
|
14
14
|
When I run "cap test"
|
|
15
15
|
Then the task is successful
|
|
16
|
+
|
|
17
|
+
Scenario: Show install task with configuration in default location
|
|
18
|
+
When I run "cap -T"
|
|
19
|
+
Then the task is successful
|
|
20
|
+
And contains "install" in the output
|
|
21
|
+
|
|
22
|
+
Scenario: Show install task with configuration in a custom location
|
|
23
|
+
And config stage file has line "desc 'Special Task'"
|
|
24
|
+
And config stage file has line "task :special_stage_task"
|
|
25
|
+
But the configuration is in a custom location
|
|
26
|
+
When I run "cap -T"
|
|
27
|
+
Then the task is successful
|
|
28
|
+
And contains "special_stage_task" in the output
|
|
@@ -3,7 +3,7 @@ Given(/^a test app with the default configuration$/) do
|
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
Given(/^servers with the roles app and web$/) do
|
|
6
|
-
vagrant_cli_command('up')
|
|
6
|
+
vagrant_cli_command('up') rescue nil
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
Given(/^a required file$/) do
|
|
@@ -20,7 +20,11 @@ Given(/^the file does not exist$/) do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
Given(/^a custom task to generate a file$/) do
|
|
23
|
-
TestApp.copy_task_to_test_app('spec/support/tasks/database.
|
|
23
|
+
TestApp.copy_task_to_test_app('spec/support/tasks/database.rake')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Given(/config stage file has line "(.*?)"/) do |line|
|
|
27
|
+
TestApp.append_to_deploy_file(line)
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
Given(/^the configuration is in a custom location$/) do
|
|
@@ -29,10 +33,10 @@ end
|
|
|
29
33
|
|
|
30
34
|
Given(/^a custom task that will simulate a failure$/) do
|
|
31
35
|
safely_remove_file(TestApp.shared_path.join('failed'))
|
|
32
|
-
TestApp.copy_task_to_test_app('spec/support/tasks/fail.
|
|
36
|
+
TestApp.copy_task_to_test_app('spec/support/tasks/fail.rake')
|
|
33
37
|
end
|
|
34
38
|
|
|
35
39
|
Given(/^a custom task to run in the event of a failure$/) do
|
|
36
40
|
safely_remove_file(TestApp.shared_path.join('failed'))
|
|
37
|
-
TestApp.copy_task_to_test_app('spec/support/tasks/failed.
|
|
41
|
+
TestApp.copy_task_to_test_app('spec/support/tasks/failed.rake')
|
|
38
42
|
end
|
|
@@ -20,20 +20,16 @@ module Capistrano
|
|
|
20
20
|
super
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def load_rakefile
|
|
24
|
-
super
|
|
25
|
-
end
|
|
26
|
-
|
|
27
23
|
def top_level_tasks
|
|
28
24
|
if tasks_without_stage_dependency.include?(@top_level_tasks.first)
|
|
29
25
|
@top_level_tasks
|
|
30
26
|
else
|
|
31
|
-
@top_level_tasks.unshift(ensure_stage)
|
|
27
|
+
@top_level_tasks.unshift(ensure_stage.to_s)
|
|
32
28
|
end
|
|
33
29
|
end
|
|
34
30
|
|
|
35
31
|
def exit_because_of_exception(ex)
|
|
36
|
-
if deploying?
|
|
32
|
+
if respond_to?(:deploying?) && deploying?
|
|
37
33
|
exit_deploy_because_of_exception(ex)
|
|
38
34
|
else
|
|
39
35
|
super
|
|
@@ -45,6 +41,7 @@ module Capistrano
|
|
|
45
41
|
def load_imports
|
|
46
42
|
if options.show_tasks
|
|
47
43
|
invoke 'load:defaults'
|
|
44
|
+
set(:stage, '')
|
|
48
45
|
Dir[deploy_config_path, stage_definitions].each { |f| add_import f }
|
|
49
46
|
end
|
|
50
47
|
|
|
@@ -79,7 +76,7 @@ module Capistrano
|
|
|
79
76
|
['--roles ROLES', '-r',
|
|
80
77
|
"Filter command to only apply to these roles (separate multiple roles with a comma)",
|
|
81
78
|
lambda { |value|
|
|
82
|
-
Configuration.env.set(:filter, :
|
|
79
|
+
Configuration.env.set(:filter, roles: value.split(","))
|
|
83
80
|
}
|
|
84
81
|
]
|
|
85
82
|
end
|
|
@@ -88,7 +85,7 @@ module Capistrano
|
|
|
88
85
|
['--hosts HOSTS', '-z',
|
|
89
86
|
"Filter command to only apply to these hosts (separate multiple hosts with a comma)",
|
|
90
87
|
lambda { |value|
|
|
91
|
-
Configuration.env.set(:filter, :
|
|
88
|
+
Configuration.env.set(:filter, hosts: value.split(","))
|
|
92
89
|
}
|
|
93
90
|
]
|
|
94
91
|
end
|
|
@@ -30,11 +30,10 @@ module Capistrano
|
|
|
30
30
|
|
|
31
31
|
def fetch(key, default=nil, &block)
|
|
32
32
|
value = fetch_for(key, default, &block)
|
|
33
|
-
|
|
34
|
-
set(key, value.call)
|
|
35
|
-
else
|
|
36
|
-
value
|
|
33
|
+
while callable_without_parameters?(value)
|
|
34
|
+
value = set(key, value.call)
|
|
37
35
|
end
|
|
36
|
+
return value
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
def role(name, hosts, options={})
|
|
@@ -99,5 +98,8 @@ module Capistrano
|
|
|
99
98
|
end
|
|
100
99
|
end
|
|
101
100
|
|
|
101
|
+
def callable_without_parameters?(x)
|
|
102
|
+
x.respond_to?(:call) && ( !x.respond_to?(:arity) || x.arity == 0)
|
|
103
|
+
end
|
|
102
104
|
end
|
|
103
105
|
end
|
|
@@ -51,7 +51,7 @@ module Capistrano
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def matches?(other)
|
|
54
|
-
hostname == other.hostname && port == other.port
|
|
54
|
+
user == other.user && hostname == other.hostname && port == other.port
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
private
|
|
@@ -86,6 +86,10 @@ module Capistrano
|
|
|
86
86
|
@roles ||= Set.new
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
def keys
|
|
90
|
+
@properties.keys
|
|
91
|
+
end
|
|
92
|
+
|
|
89
93
|
def method_missing(key, value=nil)
|
|
90
94
|
if value
|
|
91
95
|
set(lvalue(key), value)
|
data/lib/capistrano/defaults.rb
CHANGED
data/lib/capistrano/dsl.rb
CHANGED
|
@@ -26,12 +26,6 @@ module Capistrano
|
|
|
26
26
|
execute :sudo, *args
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def capturing_revisions(&block)
|
|
30
|
-
set :previous_revision, fetch_revision
|
|
31
|
-
block.call
|
|
32
|
-
set :current_revision, fetch_revision
|
|
33
|
-
end
|
|
34
|
-
|
|
35
29
|
def revision_log_message
|
|
36
30
|
fetch(:revision_log_message,
|
|
37
31
|
t(:revision_log_message,
|
|
@@ -53,11 +47,6 @@ module Capistrano
|
|
|
53
47
|
def lock(locked_version)
|
|
54
48
|
VersionValidator.new(locked_version).verify
|
|
55
49
|
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
def fetch_revision
|
|
59
|
-
capture("cd #{repo_path} && git rev-parse --short HEAD")
|
|
60
|
-
end
|
|
61
50
|
end
|
|
62
51
|
end
|
|
63
52
|
self.extend Capistrano::DSL
|
data/lib/capistrano/dsl/paths.rb
CHANGED
|
@@ -2,14 +2,16 @@ module Capistrano
|
|
|
2
2
|
module TaskEnhancements
|
|
3
3
|
def before(task, prerequisite, *args, &block)
|
|
4
4
|
prerequisite = Rake::Task.define_task(prerequisite, *args, &block) if block_given?
|
|
5
|
-
Rake::Task[task].enhance
|
|
5
|
+
Rake::Task[task].enhance do
|
|
6
|
+
Rake::Task[prerequisite].invoke(*args)
|
|
7
|
+
end
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
def after(task, post_task, *args, &block)
|
|
9
11
|
Rake::Task.define_task(post_task, *args, &block) if block_given?
|
|
10
12
|
post_task = Rake::Task[post_task]
|
|
11
13
|
Rake::Task[task].enhance do
|
|
12
|
-
post_task.invoke
|
|
14
|
+
post_task.invoke(args)
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
|
data/lib/capistrano/git.rb
CHANGED
|
@@ -18,7 +18,7 @@ class Capistrano::Git < Capistrano::SCM
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def check
|
|
21
|
-
test! :git, :'ls-remote', repo_url
|
|
21
|
+
test! :git, :'ls-remote -h', repo_url
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def clone
|
|
@@ -32,5 +32,9 @@ class Capistrano::Git < Capistrano::SCM
|
|
|
32
32
|
def release
|
|
33
33
|
git :archive, fetch(:branch), '| tar -x -C', release_path
|
|
34
34
|
end
|
|
35
|
+
|
|
36
|
+
def fetch_revision
|
|
37
|
+
context.capture(:git, "rev-parse #{fetch(:branch)}")
|
|
38
|
+
end
|
|
35
39
|
end
|
|
36
40
|
end
|
data/lib/capistrano/hg.rb
CHANGED
data/lib/capistrano/i18n.rb
CHANGED
|
@@ -15,6 +15,7 @@ en = {
|
|
|
15
15
|
keeping_releases: 'Keeping %{keep_releases} of %{releases} deployed releases on %{host}',
|
|
16
16
|
no_old_releases: 'No old releases (keeping newest %{keep_releases}) on %{host}',
|
|
17
17
|
linked_file_does_not_exist: 'linked file %{file} does not exist on %{host}',
|
|
18
|
+
cannot_rollback: 'There are no older releases to rollback to',
|
|
18
19
|
mirror_exists: "The repository mirror is at %{at}",
|
|
19
20
|
revision_log_message: 'Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}',
|
|
20
21
|
rollback_log_message: '%{user} rolled back to release %{release}',
|
data/lib/capistrano/scm.rb
CHANGED
|
@@ -28,17 +28,17 @@ module Capistrano
|
|
|
28
28
|
context.test *args
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# The repository URL
|
|
31
|
+
# The repository URL according to the context
|
|
32
32
|
def repo_url
|
|
33
33
|
context.repo_url
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
# The repository path
|
|
36
|
+
# The repository path according to the context
|
|
37
37
|
def repo_path
|
|
38
38
|
context.repo_path
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
# The release path
|
|
41
|
+
# The release path according to the context
|
|
42
42
|
def release_path
|
|
43
43
|
context.release_path
|
|
44
44
|
end
|
|
@@ -53,7 +53,7 @@ module Capistrano
|
|
|
53
53
|
|
|
54
54
|
# @abstract
|
|
55
55
|
#
|
|
56
|
-
# Your implementation should check the
|
|
56
|
+
# Your implementation should check the existence of a cache repository on
|
|
57
57
|
# the deployment target
|
|
58
58
|
#
|
|
59
59
|
# @return [Boolean]
|
|
@@ -112,5 +112,17 @@ module Capistrano
|
|
|
112
112
|
"Your SCM strategy module should provide a #release method"
|
|
113
113
|
)
|
|
114
114
|
end
|
|
115
|
+
|
|
116
|
+
# @abstract
|
|
117
|
+
#
|
|
118
|
+
# Identify the SHA of the commit that will be deployed. This will most likely involve SshKit's capture method.
|
|
119
|
+
#
|
|
120
|
+
# @return void
|
|
121
|
+
#
|
|
122
|
+
def fetch_revision
|
|
123
|
+
raise NotImplementedError.new(
|
|
124
|
+
"Your SCM strategy module should provide a #fetch_revision method"
|
|
125
|
+
)
|
|
126
|
+
end
|
|
115
127
|
end
|
|
116
128
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
load File.expand_path("../tasks/svn.rake", __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'capistrano/scm'
|
|
4
|
+
|
|
5
|
+
class Capistrano::Svn < Capistrano::SCM
|
|
6
|
+
|
|
7
|
+
# execute svn in context with arguments
|
|
8
|
+
def svn(*args)
|
|
9
|
+
args.unshift(:svn)
|
|
10
|
+
context.execute *args
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module DefaultStrategy
|
|
14
|
+
def test
|
|
15
|
+
test! " [ -d #{repo_path}/.svn ] "
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def check
|
|
19
|
+
test! :svn, :info, repo_url
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def clone
|
|
23
|
+
svn :checkout, repo_url, repo_path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def update
|
|
27
|
+
svn :update
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def release
|
|
31
|
+
svn :export, '.', release_path
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def fetch_revision
|
|
35
|
+
context.capture(:svn, "log -r HEAD -q | tail -n 2 | head -n 1 | sed s/\ \|.*/''/")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -2,10 +2,12 @@ namespace :deploy do
|
|
|
2
2
|
|
|
3
3
|
task :starting do
|
|
4
4
|
invoke 'deploy:check'
|
|
5
|
+
invoke 'deploy:set_previous_revision'
|
|
5
6
|
end
|
|
6
7
|
|
|
7
8
|
task :updating => :new_release_path do
|
|
8
9
|
invoke "#{scm}:create_release"
|
|
10
|
+
invoke "deploy:set_current_revision"
|
|
9
11
|
invoke 'deploy:symlink:shared'
|
|
10
12
|
end
|
|
11
13
|
|
|
@@ -185,18 +187,35 @@ namespace :deploy do
|
|
|
185
187
|
set_release_path
|
|
186
188
|
end
|
|
187
189
|
|
|
188
|
-
task :
|
|
190
|
+
task :rollback_release_path do
|
|
189
191
|
on release_roles(:all) do
|
|
190
|
-
|
|
192
|
+
releases = capture(:ls, '-xr', releases_path).split
|
|
193
|
+
if releases.count < 2
|
|
194
|
+
error t(:cannot_rollback)
|
|
195
|
+
exit 1
|
|
196
|
+
end
|
|
197
|
+
last_release = releases[1]
|
|
191
198
|
set_release_path(last_release)
|
|
199
|
+
set(:rollback_timestamp, last_release)
|
|
192
200
|
end
|
|
193
201
|
end
|
|
194
202
|
|
|
195
|
-
|
|
203
|
+
desc "Place a REVISION file with the current revision SHA in the current release path"
|
|
204
|
+
task :set_current_revision do
|
|
205
|
+
invoke "#{scm}:set_current_revision"
|
|
196
206
|
on release_roles(:all) do
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
within release_path do
|
|
208
|
+
execute :echo, "\"#{fetch(:current_revision)}\" >> REVISION"
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
task :set_previous_revision do
|
|
214
|
+
on release_roles(:all) do
|
|
215
|
+
target = release_path.join('REVISION')
|
|
216
|
+
if test "[ -f #{target} ]"
|
|
217
|
+
set(:previous_revision, capture(:cat, target, '2>/dev/null'))
|
|
218
|
+
end
|
|
200
219
|
end
|
|
201
220
|
end
|
|
202
221
|
|
|
@@ -49,7 +49,7 @@ namespace :git do
|
|
|
49
49
|
task update: :'git:clone' do
|
|
50
50
|
on release_roles :all do
|
|
51
51
|
within repo_path do
|
|
52
|
-
|
|
52
|
+
with fetch(:git_environmental_variables) do
|
|
53
53
|
strategy.update
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -67,5 +67,15 @@ namespace :git do
|
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
|
-
end
|
|
71
70
|
|
|
71
|
+
desc 'Determine the revision that will be deployed'
|
|
72
|
+
task :set_current_revision do
|
|
73
|
+
on release_roles :all do
|
|
74
|
+
within repo_path do
|
|
75
|
+
with fetch(:git_environmental_variables) do
|
|
76
|
+
set :current_revision, strategy.fetch_revision
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -40,4 +40,13 @@ namespace :hg do
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
desc 'Determine the revision that will be deployed'
|
|
45
|
+
task :set_current_revision do
|
|
46
|
+
on release_roles :all do
|
|
47
|
+
within repo_path do
|
|
48
|
+
set :current_revision, strategy.fetch_revision
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
43
52
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
namespace :svn do
|
|
2
|
+
def strategy
|
|
3
|
+
@strategy ||= Capistrano::Svn.new(self, fetch(:svn_strategy, Capistrano::Svn::DefaultStrategy))
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
desc 'Check that the repo is reachable'
|
|
7
|
+
task :check do
|
|
8
|
+
on release_roles :all do
|
|
9
|
+
strategy.check
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc 'Clone the repo to the cache'
|
|
14
|
+
task :clone do
|
|
15
|
+
on release_roles :all do
|
|
16
|
+
if strategy.test
|
|
17
|
+
info t(:mirror_exists, at: repo_path)
|
|
18
|
+
else
|
|
19
|
+
within deploy_path do
|
|
20
|
+
strategy.clone
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc 'Pull changes from the remote repo'
|
|
27
|
+
task :update => :'svn:clone' do
|
|
28
|
+
on release_roles :all do
|
|
29
|
+
within repo_path do
|
|
30
|
+
strategy.update
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc 'Copy repo to releases'
|
|
36
|
+
task :create_release => :'svn:update' do
|
|
37
|
+
on release_roles :all do
|
|
38
|
+
within repo_path do
|
|
39
|
+
strategy.release
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc 'Determine the revision that will be deployed'
|
|
45
|
+
task :set_current_revision do
|
|
46
|
+
on release_roles :all do
|
|
47
|
+
within repo_path do
|
|
48
|
+
set :current_revision, strategy.fetch_revision
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -22,4 +22,4 @@ require 'capistrano/deploy'
|
|
|
22
22
|
# require 'capistrano/rails/migrations'
|
|
23
23
|
|
|
24
24
|
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
|
|
25
|
-
Dir.glob('lib/capistrano/tasks/*.
|
|
25
|
+
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
|
|
@@ -5,7 +5,7 @@ set :application, 'my_app_name'
|
|
|
5
5
|
set :repo_url, 'git@example.com:me/my_repo.git'
|
|
6
6
|
|
|
7
7
|
# Default branch is :master
|
|
8
|
-
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
|
|
8
|
+
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
|
|
9
9
|
|
|
10
10
|
# Default deploy_to directory is /var/www/my_app
|
|
11
11
|
# set :deploy_to, '/var/www/my_app'
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
# Simple Role Syntax
|
|
2
2
|
# ==================
|
|
3
|
-
# Supports bulk-adding hosts to roles, the primary
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
3
|
+
# Supports bulk-adding hosts to roles, the primary server in each group
|
|
4
|
+
# is considered to be the first unless any hosts have the primary
|
|
5
|
+
# property set. Don't declare `role :all`, it's a meta role.
|
|
6
|
+
|
|
7
7
|
role :app, %w{deploy@example.com}
|
|
8
8
|
role :web, %w{deploy@example.com}
|
|
9
9
|
role :db, %w{deploy@example.com}
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
# Extended Server Syntax
|
|
12
13
|
# ======================
|
|
13
|
-
# This can be used to drop a more detailed server
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
|
|
14
|
+
# This can be used to drop a more detailed server definition into the
|
|
15
|
+
# server list. The second argument is a, or duck-types, Hash and is
|
|
16
|
+
# used to set extended properties on the server.
|
|
17
|
+
|
|
17
18
|
server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
20
|
+
|
|
21
|
+
# Custom SSH Options
|
|
22
|
+
# ==================
|
|
23
|
+
# You may pass any option but keep in mind that net/ssh understands a
|
|
24
|
+
# limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start).
|
|
25
|
+
#
|
|
26
|
+
# Global options
|
|
27
|
+
# --------------
|
|
23
28
|
# set :ssh_options, {
|
|
24
29
|
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
25
30
|
# forward_agent: false,
|
|
26
31
|
# auth_methods: %w(password)
|
|
27
32
|
# }
|
|
28
|
-
#
|
|
33
|
+
#
|
|
34
|
+
# And/or per server (overrides global)
|
|
35
|
+
# ------------------------------------
|
|
29
36
|
# server 'example.com',
|
|
30
37
|
# user: 'user_name',
|
|
31
38
|
# roles: %w{web app},
|
|
@@ -36,4 +43,3 @@ server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
|
|
|
36
43
|
# auth_methods: %w(publickey password)
|
|
37
44
|
# # password: 'please use keys'
|
|
38
45
|
# }
|
|
39
|
-
# setting per server overrides global ssh_options
|
data/lib/capistrano/version.rb
CHANGED
|
@@ -201,16 +201,18 @@ describe Capistrano::DSL do
|
|
|
201
201
|
describe 'when defining a host using a combination of the `server` and `role` syntax' do
|
|
202
202
|
|
|
203
203
|
before do
|
|
204
|
-
dsl.server 'example1.com:1234', roles: %w{
|
|
204
|
+
dsl.server 'db@example1.com:1234', roles: %w{db}, active: true
|
|
205
|
+
dsl.server 'root@example1.com:1234', roles: %w{web}, active: true
|
|
205
206
|
dsl.server 'example1.com:5678', roles: %w{web}, active: true
|
|
207
|
+
dsl.role :app, %w{deployer@example1.com:1234}
|
|
206
208
|
dsl.role :app, %w{example1.com:5678}
|
|
207
209
|
end
|
|
208
210
|
|
|
209
211
|
describe 'fetching all servers' do
|
|
210
|
-
subject { dsl.roles(:all).map { |server| "#{server.hostname}:#{server.port}" } }
|
|
212
|
+
subject { dsl.roles(:all).map { |server| "#{server.user}@#{server.hostname}:#{server.port}" } }
|
|
211
213
|
|
|
212
|
-
it 'creates a server instance for each unique host:port combination' do
|
|
213
|
-
expect(subject).to eq %w{example1.com:1234 example1.com:5678}
|
|
214
|
+
it 'creates a server instance for each unique user@host:port combination' do
|
|
215
|
+
expect(subject).to eq %w{db@example1.com:1234 root@example1.com:1234 @example1.com:5678 deployer@example1.com:1234}
|
|
214
216
|
end
|
|
215
217
|
end
|
|
216
218
|
|
|
@@ -220,7 +222,7 @@ describe Capistrano::DSL do
|
|
|
220
222
|
end
|
|
221
223
|
|
|
222
224
|
it 'roles defined using the `role` syntax are included' do
|
|
223
|
-
expect(dsl.roles(:app)).to have(
|
|
225
|
+
expect(dsl.roles(:app)).to have(2).items
|
|
224
226
|
end
|
|
225
227
|
end
|
|
226
228
|
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
module Capistrano
|
|
4
4
|
class Configuration
|
|
5
5
|
describe Server do
|
|
6
|
-
let(:server) { Server.new('hostname:1234') }
|
|
6
|
+
let(:server) { Server.new('root@hostname:1234') }
|
|
7
7
|
|
|
8
8
|
describe 'adding a role' do
|
|
9
9
|
subject { server.add_role(:test) }
|
|
@@ -35,23 +35,23 @@ module Capistrano
|
|
|
35
35
|
describe 'comparing identity' do
|
|
36
36
|
subject { server.matches? Server[hostname] }
|
|
37
37
|
|
|
38
|
-
context 'with the same hostname' do
|
|
39
|
-
let(:hostname) { 'hostname:1234' }
|
|
38
|
+
context 'with the same user, hostname and port' do
|
|
39
|
+
let(:hostname) { 'root@hostname:1234' }
|
|
40
40
|
it { should be_true }
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
context 'with
|
|
44
|
-
let(:hostname) { '
|
|
45
|
-
it { should
|
|
43
|
+
context 'with a different user' do
|
|
44
|
+
let(:hostname) { 'deployer@hostname:1234' }
|
|
45
|
+
it { should be_false }
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
context 'with
|
|
49
|
-
let(:hostname) { 'hostname:5678' }
|
|
48
|
+
context 'with a different port' do
|
|
49
|
+
let(:hostname) { 'root@hostname:5678' }
|
|
50
50
|
it { should be_false }
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
context 'with a different hostname' do
|
|
54
|
-
let(:hostname) { 'otherserver' }
|
|
54
|
+
let(:hostname) { 'root@otherserver:1234' }
|
|
55
55
|
it { should be_false }
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -104,12 +104,18 @@ module Capistrano
|
|
|
104
104
|
expect(servers.roles_for([:app]).first.hostname).to eq '1'
|
|
105
105
|
expect(servers.roles_for([:web]).first.hostname).to eq '1'
|
|
106
106
|
expect(servers.roles_for([:all]).first.properties.test).to eq :value
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
servers.add_host('
|
|
112
|
-
|
|
107
|
+
expect(servers.roles_for([:all]).first.properties.keys).to eq [:test]
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'can accept multiple servers with the same hostname but different ports or users' do
|
|
111
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, port: 12)
|
|
112
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, port: 34)
|
|
113
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root')
|
|
114
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer')
|
|
115
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root', port: 34)
|
|
116
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 34)
|
|
117
|
+
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 56)
|
|
118
|
+
servers.should have(8).items
|
|
113
119
|
end
|
|
114
120
|
end
|
|
115
121
|
|
|
@@ -61,6 +61,48 @@ module Capistrano
|
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
+
context 'value is a lambda' do
|
|
65
|
+
subject { config.fetch(:key, lambda { :lambda } ) }
|
|
66
|
+
it 'calls the lambda' do
|
|
67
|
+
expect(subject).to eq :lambda
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context 'value inside proc inside a proc' do
|
|
72
|
+
subject { config.fetch(:key, Proc.new { Proc.new { "some value" } } ) }
|
|
73
|
+
it 'calls all procs and lambdas' do
|
|
74
|
+
expect(subject).to eq "some value"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context 'value inside lambda inside a lambda' do
|
|
79
|
+
subject { config.fetch(:key, lambda { lambda { "some value" } } ) }
|
|
80
|
+
it 'calls all procs and lambdas' do
|
|
81
|
+
expect(subject).to eq "some value"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context 'value inside lambda inside a proc' do
|
|
86
|
+
subject { config.fetch(:key, Proc.new { lambda { "some value" } } ) }
|
|
87
|
+
it 'calls all procs and lambdas' do
|
|
88
|
+
expect(subject).to eq "some value"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context 'value inside proc inside a lambda' do
|
|
93
|
+
subject { config.fetch(:key, lambda { Proc.new { "some value" } } ) }
|
|
94
|
+
it 'calls all procs and lambdas' do
|
|
95
|
+
expect(subject).to eq "some value"
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context 'lambda with parameters' do
|
|
100
|
+
subject { config.fetch(:key, lambda { |c| c }).call(42) }
|
|
101
|
+
it 'is returned as a lambda' do
|
|
102
|
+
expect(subject).to eq 42
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
64
106
|
context 'block is passed to fetch' do
|
|
65
107
|
subject { config.fetch(:key, :default) { fail 'we need this!' } }
|
|
66
108
|
|
|
@@ -31,7 +31,7 @@ module Capistrano
|
|
|
31
31
|
describe "#check" do
|
|
32
32
|
it "should test the repo url" do
|
|
33
33
|
context.expects(:repo_url).returns(:url)
|
|
34
|
-
context.expects(:test).with(:git, :'ls-remote', :url).returns(true)
|
|
34
|
+
context.expects(:test).with(:git, :'ls-remote -h', :url).returns(true)
|
|
35
35
|
|
|
36
36
|
subject.check
|
|
37
37
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
require 'capistrano/svn'
|
|
4
|
+
|
|
5
|
+
module Capistrano
|
|
6
|
+
describe Svn do
|
|
7
|
+
let(:context) { Class.new.new }
|
|
8
|
+
subject { Capistrano::Svn.new(context, Capistrano::Svn::DefaultStrategy) }
|
|
9
|
+
|
|
10
|
+
describe "#svn" do
|
|
11
|
+
it "should call execute svn in the context, with arguments" do
|
|
12
|
+
context.expects(:execute).with(:svn, :init)
|
|
13
|
+
subject.svn(:init)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe Svn::DefaultStrategy do
|
|
19
|
+
let(:context) { Class.new.new }
|
|
20
|
+
subject { Capistrano::Svn.new(context, Capistrano::Svn::DefaultStrategy) }
|
|
21
|
+
|
|
22
|
+
describe "#test" do
|
|
23
|
+
it "should call test for repo HEAD" do
|
|
24
|
+
context.expects(:repo_path).returns("/path/to/repo")
|
|
25
|
+
context.expects(:test).with " [ -d /path/to/repo/.svn ] "
|
|
26
|
+
|
|
27
|
+
subject.test
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "#check" do
|
|
32
|
+
it "should test the repo url" do
|
|
33
|
+
context.expects(:repo_url).returns(:url)
|
|
34
|
+
context.expects(:test).with(:svn, :info, :url).returns(true)
|
|
35
|
+
|
|
36
|
+
subject.check
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#clone" do
|
|
41
|
+
it "should run svn checkout" do
|
|
42
|
+
context.expects(:repo_url).returns(:url)
|
|
43
|
+
context.expects(:repo_path).returns(:path)
|
|
44
|
+
|
|
45
|
+
context.expects(:execute).with(:svn, :checkout, :url, :path)
|
|
46
|
+
|
|
47
|
+
subject.clone
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "#update" do
|
|
52
|
+
it "should run svn update" do
|
|
53
|
+
context.expects(:execute).with(:svn, :update)
|
|
54
|
+
|
|
55
|
+
subject.update
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#release" do
|
|
60
|
+
it "should run svn export" do
|
|
61
|
+
context.expects(:release_path).returns(:path)
|
|
62
|
+
|
|
63
|
+
context.expects(:execute).with(:svn, :export, '.', :path)
|
|
64
|
+
|
|
65
|
+
subject.release
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/spec/support/test_app.rb
CHANGED
|
@@ -57,6 +57,12 @@ module TestApp
|
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
def append_to_deploy_file(config)
|
|
61
|
+
File.open(test_stage_path, 'a') do |file|
|
|
62
|
+
file.write config + "\n"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
60
66
|
def prepend_to_capfile(config)
|
|
61
67
|
current_capfile = File.read(capfile)
|
|
62
68
|
File.open(capfile, 'w') do |file|
|
|
@@ -78,10 +84,11 @@ module TestApp
|
|
|
78
84
|
end
|
|
79
85
|
|
|
80
86
|
def run(command)
|
|
87
|
+
output = nil
|
|
81
88
|
Dir.chdir(test_app_path) do
|
|
82
|
-
%x[#{command}]
|
|
89
|
+
output = %x[#{command}]
|
|
83
90
|
end
|
|
84
|
-
$?.success
|
|
91
|
+
[$?.success?, output]
|
|
85
92
|
end
|
|
86
93
|
|
|
87
94
|
def stage
|
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: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom Clements
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-
|
|
12
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sshkit
|
|
@@ -102,7 +102,6 @@ files:
|
|
|
102
102
|
- Rakefile
|
|
103
103
|
- bin/cap
|
|
104
104
|
- bin/capify
|
|
105
|
-
- capistrano-public_cert.pem
|
|
106
105
|
- capistrano.gemspec
|
|
107
106
|
- features/configuration.feature
|
|
108
107
|
- features/deploy.feature
|
|
@@ -140,12 +139,14 @@ files:
|
|
|
140
139
|
- lib/capistrano/install.rb
|
|
141
140
|
- lib/capistrano/scm.rb
|
|
142
141
|
- lib/capistrano/setup.rb
|
|
142
|
+
- lib/capistrano/svn.rb
|
|
143
143
|
- lib/capistrano/tasks/console.rake
|
|
144
144
|
- lib/capistrano/tasks/deploy.rake
|
|
145
145
|
- lib/capistrano/tasks/framework.rake
|
|
146
146
|
- lib/capistrano/tasks/git.rake
|
|
147
147
|
- lib/capistrano/tasks/hg.rake
|
|
148
148
|
- lib/capistrano/tasks/install.rake
|
|
149
|
+
- lib/capistrano/tasks/svn.rake
|
|
149
150
|
- lib/capistrano/templates/Capfile
|
|
150
151
|
- lib/capistrano/templates/deploy.rb.erb
|
|
151
152
|
- lib/capistrano/templates/stage.rb.erb
|
|
@@ -165,15 +166,16 @@ files:
|
|
|
165
166
|
- spec/lib/capistrano/git_spec.rb
|
|
166
167
|
- spec/lib/capistrano/hg_spec.rb
|
|
167
168
|
- spec/lib/capistrano/scm_spec.rb
|
|
169
|
+
- spec/lib/capistrano/svn_spec.rb
|
|
168
170
|
- spec/lib/capistrano/version_validator_spec.rb
|
|
169
171
|
- spec/lib/capistrano_spec.rb
|
|
170
172
|
- spec/spec_helper.rb
|
|
171
173
|
- spec/support/.gitignore
|
|
172
174
|
- spec/support/Vagrantfile
|
|
173
175
|
- spec/support/matchers.rb
|
|
174
|
-
- spec/support/tasks/database.
|
|
175
|
-
- spec/support/tasks/fail.
|
|
176
|
-
- spec/support/tasks/failed.
|
|
176
|
+
- spec/support/tasks/database.rake
|
|
177
|
+
- spec/support/tasks/fail.rake
|
|
178
|
+
- spec/support/tasks/failed.rake
|
|
177
179
|
- spec/support/test_app.rb
|
|
178
180
|
homepage: http://capistranorb.com/
|
|
179
181
|
licenses:
|
|
@@ -227,14 +229,15 @@ test_files:
|
|
|
227
229
|
- spec/lib/capistrano/git_spec.rb
|
|
228
230
|
- spec/lib/capistrano/hg_spec.rb
|
|
229
231
|
- spec/lib/capistrano/scm_spec.rb
|
|
232
|
+
- spec/lib/capistrano/svn_spec.rb
|
|
230
233
|
- spec/lib/capistrano/version_validator_spec.rb
|
|
231
234
|
- spec/lib/capistrano_spec.rb
|
|
232
235
|
- spec/spec_helper.rb
|
|
233
236
|
- spec/support/.gitignore
|
|
234
237
|
- spec/support/Vagrantfile
|
|
235
238
|
- spec/support/matchers.rb
|
|
236
|
-
- spec/support/tasks/database.
|
|
237
|
-
- spec/support/tasks/fail.
|
|
238
|
-
- spec/support/tasks/failed.
|
|
239
|
+
- spec/support/tasks/database.rake
|
|
240
|
+
- spec/support/tasks/fail.rake
|
|
241
|
+
- spec/support/tasks/failed.rake
|
|
239
242
|
- spec/support/test_app.rb
|
|
240
243
|
has_rdoc:
|
data/capistrano-public_cert.pem
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
|
2
|
-
MIIDkjCCAnqgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMRIwEAYDVQQDDAlnZW1t
|
|
3
|
-
YXN0ZXIxHDAaBgoJkiaJk/IsZAEZFgxjYXBpc3RyYW5vcmIxEzARBgoJkiaJk/Is
|
|
4
|
-
ZAEZFgNjb20wHhcNMTMwNjI4MTM0MzQ1WhcNMTQwNjI4MTM0MzQ1WjBHMRIwEAYD
|
|
5
|
-
VQQDDAlnZW1tYXN0ZXIxHDAaBgoJkiaJk/IsZAEZFgxjYXBpc3RyYW5vcmIxEzAR
|
|
6
|
-
BgoJkiaJk/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
|
|
7
|
-
AQDnuMT+SoCTQoxEOma65Vf9ftibHTzfaZPGSNcheguiFa3/Mc69/xurtUa7bGY8
|
|
8
|
-
ZyuJbd2pb4pqhx7PcVlByJnBQCmOHzZPzn6wVa5n4n8/VBccYcFNePdPj8+KK13x
|
|
9
|
-
+97E6mjNZJtf4BZm4tZD6Ztyq90+mQ0WeoseYfYdm+ZJ9BNFdB2EHmTnh983MHMj
|
|
10
|
-
WNn52ZC2pAHDRuxKAOj5yq8IZWA8B/IWNjMXQCJbM9eaH0+vVvquC2RyprpkfoqQ
|
|
11
|
-
Xb7BJA2hftizHUMk4LOldNvy220GHjKL0Ot7tlGcD2DzaZNN0aPUfezz306ytsMp
|
|
12
|
-
KDYYLbLcg63TPHFHu1fzyQG9AgMBAAGjgYgwgYUwCQYDVR0TBAIwADALBgNVHQ8E
|
|
13
|
-
BAMCBLAwHQYDVR0OBBYEFEzXgfsvOB8Aw2b+Md3t3O9PUGZCMCUGA1UdEQQeMByB
|
|
14
|
-
GmdlbW1hc3RlckBjYXBpc3RyYW5vcmIuY29tMCUGA1UdEgQeMByBGmdlbW1hc3Rl
|
|
15
|
-
ckBjYXBpc3RyYW5vcmIuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQCnS7Pcy/srhZCb
|
|
16
|
-
TrUNkCTHI4QEURAWRNYFLL9TCCl3oyKkwW6aZxarpQbJK3Es99sugsKh/sKijOIE
|
|
17
|
-
xhflvSNN59Zc/BETve1y0VktN+94GiQQ1F82SmRwmY2tJJD7C3jQ6Og6pX7eNBWZ
|
|
18
|
-
W1su8leIv8sj3o5Vdn/Le1HKVXMakFICq9HdLnIH1jW2Brfthlc2ujAg0cOU58GC
|
|
19
|
-
wNkME+L45pR9zggNpbBY23mlbAicPrsmybEdk9SOdaOCgxh+fyGx6Q2n0m5YAXgN
|
|
20
|
-
KVoU0DazqHs6BVyJaajxht4kCpPDD1wUqCvwlOQtotdwD7CCGCPdcYgf6fAp4yQZ
|
|
21
|
-
jC76QR6/
|
|
22
|
-
-----END CERTIFICATE-----
|