capistrano 3.6.1 → 3.7.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/issue_template.md +19 -0
  3. data/.github/pull_request_template.md +26 -0
  4. data/.gitignore +1 -0
  5. data/.travis.yml +5 -1
  6. data/CHANGELOG.md +27 -1
  7. data/DEVELOPMENT.md +7 -1
  8. data/README.md +3 -4
  9. data/capistrano.gemspec +1 -1
  10. data/features/support/vagrant_helpers.rb +3 -5
  11. data/lib/capistrano/all.rb +1 -0
  12. data/lib/capistrano/configuration.rb +12 -2
  13. data/lib/capistrano/configuration/host_filter.rb +1 -1
  14. data/lib/capistrano/configuration/plugin_installer.rb +20 -2
  15. data/lib/capistrano/configuration/role_filter.rb +1 -1
  16. data/lib/capistrano/configuration/scm_resolver.rb +144 -0
  17. data/lib/capistrano/configuration/validated_variables.rb +3 -4
  18. data/lib/capistrano/defaults.rb +3 -1
  19. data/lib/capistrano/doctor/variables_doctor.rb +1 -1
  20. data/lib/capistrano/dsl/env.rb +2 -9
  21. data/lib/capistrano/dsl/paths.rb +1 -1
  22. data/lib/capistrano/dsl/task_enhancements.rb +0 -8
  23. data/lib/capistrano/scm/git.rb +73 -0
  24. data/lib/capistrano/scm/hg.rb +48 -0
  25. data/lib/capistrano/scm/plugin.rb +13 -0
  26. data/lib/capistrano/scm/svn.rb +47 -0
  27. data/lib/capistrano/{tasks → scm/tasks}/git.rake +9 -24
  28. data/lib/capistrano/{tasks → scm/tasks}/hg.rake +11 -10
  29. data/lib/capistrano/{tasks → scm/tasks}/svn.rake +11 -10
  30. data/lib/capistrano/setup.rb +1 -1
  31. data/lib/capistrano/tasks/deploy.rake +0 -3
  32. data/lib/capistrano/templates/Capfile +18 -7
  33. data/lib/capistrano/templates/deploy.rb.erb +7 -10
  34. data/lib/capistrano/templates/stage.rb.erb +7 -7
  35. data/lib/capistrano/version.rb +1 -1
  36. data/lib/capistrano/version_validator.rb +2 -5
  37. data/spec/lib/capistrano/configuration/host_filter_spec.rb +5 -0
  38. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  39. data/spec/lib/capistrano/configuration/role_filter_spec.rb +17 -1
  40. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +0 -7
  41. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +0 -15
  42. data/spec/lib/capistrano/scm/git_spec.rb +131 -0
  43. data/spec/lib/capistrano/scm/hg_spec.rb +104 -0
  44. data/spec/lib/capistrano/scm/svn_spec.rb +116 -0
  45. data/spec/lib/capistrano/scm_spec.rb +1 -1
  46. metadata +23 -20
  47. data/features/remote_file_task.feature +0 -14
  48. data/issue_template.md +0 -21
  49. data/lib/capistrano/git.rb +0 -54
  50. data/lib/capistrano/hg.rb +0 -43
  51. data/lib/capistrano/svn.rb +0 -42
  52. data/spec/lib/capistrano/git_spec.rb +0 -109
  53. data/spec/lib/capistrano/hg_spec.rb +0 -90
  54. data/spec/lib/capistrano/svn_spec.rb +0 -105
@@ -0,0 +1,104 @@
1
+ require "spec_helper"
2
+
3
+ require "capistrano/scm/hg"
4
+
5
+ module Capistrano
6
+ describe SCM::Hg do
7
+ subject { Capistrano::SCM::Hg.new }
8
+
9
+ # This allows us to easily use `set`, `fetch`, etc. in the examples.
10
+ let(:env) { Capistrano::Configuration.env }
11
+
12
+ # Stub the SSHKit backend so we can set up expectations without the plugin
13
+ # actually executing any commands.
14
+ let(:backend) { stub }
15
+ before { SSHKit::Backend.stubs(:current).returns(backend) }
16
+
17
+ # Mimic the deploy flow tasks so that the plugin can register its hooks.
18
+ before do
19
+ Rake::Task.define_task("deploy:new_release_path")
20
+ Rake::Task.define_task("deploy:check")
21
+ Rake::Task.define_task("deploy:set_current_revision")
22
+ end
23
+
24
+ # Clean up any tasks or variables that the plugin defined.
25
+ after do
26
+ Rake::Task.clear
27
+ Capistrano::Configuration.reset!
28
+ end
29
+
30
+ describe "#hg" do
31
+ it "should call execute hg in the context, with arguments" do
32
+ backend.expects(:execute).with(:hg, :init)
33
+ subject.hg(:init)
34
+ end
35
+ end
36
+
37
+ describe "#repo_mirror_exists?" do
38
+ it "should call test for repo HEAD" do
39
+ env.set(:repo_path, "/path/to/repo")
40
+ backend.expects(:test).with " [ -d /path/to/repo/.hg ] "
41
+
42
+ subject.repo_mirror_exists?
43
+ end
44
+ end
45
+
46
+ describe "#check_repo_is_reachable" do
47
+ it "should test the repo url" do
48
+ env.set(:repo_url, :url)
49
+ backend.expects(:execute).with(:hg, "id", :url)
50
+
51
+ subject.check_repo_is_reachable
52
+ end
53
+ end
54
+
55
+ describe "#clone_repo" do
56
+ it "should run hg clone" do
57
+ env.set(:repo_url, :url)
58
+ env.set(:repo_path, "path")
59
+
60
+ backend.expects(:execute).with(:hg, "clone", "--noupdate", :url, "path")
61
+
62
+ subject.clone_repo
63
+ end
64
+ end
65
+
66
+ describe "#update_mirror" do
67
+ it "should run hg update" do
68
+ backend.expects(:execute).with(:hg, "pull")
69
+
70
+ subject.update_mirror
71
+ end
72
+ end
73
+
74
+ describe "#archive_to_release_path" do
75
+ it "should run hg archive without a subtree" do
76
+ env.set(:branch, :branch)
77
+ env.set(:release_path, "path")
78
+
79
+ backend.expects(:execute).with(:hg, "archive", "path", "--rev", :branch)
80
+
81
+ subject.archive_to_release_path
82
+ end
83
+
84
+ it "should run hg archive with a subtree" do
85
+ env.set(:repo_tree, "tree")
86
+ env.set(:branch, :branch)
87
+ env.set(:release_path, "path")
88
+
89
+ backend.expects(:execute).with(:hg, "archive --type tgz -p . -I", "tree", "--rev", :branch, "| tar -x --strip-components 1 -f - -C", "path")
90
+
91
+ subject.archive_to_release_path
92
+ end
93
+ end
94
+
95
+ describe "#fetch_revision" do
96
+ it "should capture hg log" do
97
+ env.set(:branch, :branch)
98
+ backend.expects(:capture).with(:hg, "log --rev branch --template \"{node}\n\"").returns("01abcde")
99
+ revision = subject.fetch_revision
100
+ expect(revision).to eq("01abcde")
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,116 @@
1
+ require "spec_helper"
2
+
3
+ require "capistrano/scm/svn"
4
+
5
+ module Capistrano
6
+ describe SCM::Svn do
7
+ subject { Capistrano::SCM::Svn.new }
8
+
9
+ # This allows us to easily use `set`, `fetch`, etc. in the examples.
10
+ let(:env) { Capistrano::Configuration.env }
11
+
12
+ # Stub the SSHKit backend so we can set up expectations without the plugin
13
+ # actually executing any commands.
14
+ let(:backend) { stub }
15
+ before { SSHKit::Backend.stubs(:current).returns(backend) }
16
+
17
+ # Mimic the deploy flow tasks so that the plugin can register its hooks.
18
+ before do
19
+ Rake::Task.define_task("deploy:new_release_path")
20
+ Rake::Task.define_task("deploy:check")
21
+ Rake::Task.define_task("deploy:set_current_revision")
22
+ end
23
+
24
+ # Clean up any tasks or variables that the plugin defined.
25
+ after do
26
+ Rake::Task.clear
27
+ Capistrano::Configuration.reset!
28
+ end
29
+
30
+ describe "#svn" do
31
+ it "should call execute svn in the context, with arguments" do
32
+ env.set(:svn_username, "someuser")
33
+ env.set(:svn_password, "somepassword")
34
+ backend.expects(:execute).with(:svn, :init, "--username someuser", "--password somepassword")
35
+ subject.svn(:init)
36
+ end
37
+ end
38
+
39
+ describe "#repo_mirror_exists?" do
40
+ it "should call test for repo HEAD" do
41
+ env.set(:repo_path, "/path/to/repo")
42
+ backend.expects(:test).with " [ -d /path/to/repo/.svn ] "
43
+
44
+ subject.repo_mirror_exists?
45
+ end
46
+ end
47
+
48
+ describe "#check_repo_is_reachable" do
49
+ it "should test the repo url" do
50
+ env.set(:repo_url, :url)
51
+ env.set(:svn_username, "someuser")
52
+ env.set(:svn_password, "somepassword")
53
+ backend.expects(:test).with(:svn, :info, :url, "--username someuser", "--password somepassword").returns(true)
54
+
55
+ subject.check_repo_is_reachable
56
+ end
57
+ end
58
+
59
+ describe "#clone_repo" do
60
+ it "should run svn checkout" do
61
+ env.set(:repo_url, :url)
62
+ env.set(:repo_path, "path")
63
+ env.set(:svn_username, "someuser")
64
+ env.set(:svn_password, "somepassword")
65
+
66
+ backend.expects(:execute).with(:svn, :checkout, :url, "path", "--username someuser", "--password somepassword")
67
+
68
+ subject.clone_repo
69
+ end
70
+ end
71
+
72
+ describe "#update_mirror" do
73
+ it "should run svn update" do
74
+ env.set(:svn_username, "someuser")
75
+ env.set(:svn_password, "somepassword")
76
+ backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
77
+
78
+ subject.update_mirror
79
+ end
80
+
81
+ context "for specific revision" do
82
+ it "should run svn update" do
83
+ env.set(:svn_username, "someuser")
84
+ env.set(:svn_password, "somepassword")
85
+ env.set(:svn_revision, "12345")
86
+ backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword", "--revision 12345")
87
+
88
+ subject.update_mirror
89
+ end
90
+ end
91
+ end
92
+
93
+ describe "#archive_to_release_path" do
94
+ it "should run svn export" do
95
+ env.set(:release_path, "path")
96
+ env.set(:svn_username, "someuser")
97
+ env.set(:svn_password, "somepassword")
98
+
99
+ backend.expects(:execute).with(:svn, :export, "--force", ".", "path", "--username someuser", "--password somepassword")
100
+
101
+ subject.archive_to_release_path
102
+ end
103
+ end
104
+
105
+ describe "#fetch_revision" do
106
+ it "should capture svn version" do
107
+ env.set(:repo_path, "path")
108
+
109
+ backend.expects(:capture).with(:svnversion, "path").returns("12345")
110
+
111
+ revision = subject.fetch_revision
112
+ expect(revision).to eq("12345")
113
+ end
114
+ end
115
+ end
116
+ end
@@ -26,7 +26,7 @@ module BlindStrategy; end
26
26
 
27
27
  module Capistrano
28
28
  describe SCM do
29
- let(:context) { Class.new.new }
29
+ let(:context) { mock }
30
30
 
31
31
  describe "#initialize" do
32
32
  subject { Capistrano::SCM.new(context, DummyStrategy) }
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.6.1
4
+ version: 3.7.0.beta1
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: 2016-08-24 00:00:00.000000000 Z
12
+ date: 2016-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: airbrussh
@@ -134,6 +134,8 @@ executables:
134
134
  extensions: []
135
135
  extra_rdoc_files: []
136
136
  files:
137
+ - ".github/issue_template.md"
138
+ - ".github/pull_request_template.md"
137
139
  - ".gitignore"
138
140
  - ".rubocop.yml"
139
141
  - ".travis.yml"
@@ -154,7 +156,6 @@ files:
154
156
  - features/deploy_failure.feature
155
157
  - features/doctor.feature
156
158
  - features/installation.feature
157
- - features/remote_file_task.feature
158
159
  - features/sshconnect.feature
159
160
  - features/stage_failure.feature
160
161
  - features/step_definitions/assertions.rb
@@ -163,7 +164,6 @@ files:
163
164
  - features/support/env.rb
164
165
  - features/support/remote_command_helpers.rb
165
166
  - features/support/vagrant_helpers.rb
166
- - issue_template.md
167
167
  - lib/Capfile
168
168
  - lib/capistrano.rb
169
169
  - lib/capistrano/all.rb
@@ -176,6 +176,7 @@ files:
176
176
  - lib/capistrano/configuration/plugin_installer.rb
177
177
  - lib/capistrano/configuration/question.rb
178
178
  - lib/capistrano/configuration/role_filter.rb
179
+ - lib/capistrano/configuration/scm_resolver.rb
179
180
  - lib/capistrano/configuration/server.rb
180
181
  - lib/capistrano/configuration/servers.rb
181
182
  - lib/capistrano/configuration/validated_variables.rb
@@ -196,24 +197,25 @@ files:
196
197
  - lib/capistrano/dsl/stages.rb
197
198
  - lib/capistrano/dsl/task_enhancements.rb
198
199
  - lib/capistrano/framework.rb
199
- - lib/capistrano/git.rb
200
- - lib/capistrano/hg.rb
201
200
  - lib/capistrano/i18n.rb
202
201
  - lib/capistrano/immutable_task.rb
203
202
  - lib/capistrano/install.rb
204
203
  - lib/capistrano/plugin.rb
205
204
  - lib/capistrano/proc_helpers.rb
206
205
  - lib/capistrano/scm.rb
206
+ - lib/capistrano/scm/git.rb
207
+ - lib/capistrano/scm/hg.rb
208
+ - lib/capistrano/scm/plugin.rb
209
+ - lib/capistrano/scm/svn.rb
210
+ - lib/capistrano/scm/tasks/git.rake
211
+ - lib/capistrano/scm/tasks/hg.rake
212
+ - lib/capistrano/scm/tasks/svn.rake
207
213
  - lib/capistrano/setup.rb
208
- - lib/capistrano/svn.rb
209
214
  - lib/capistrano/tasks/console.rake
210
215
  - lib/capistrano/tasks/deploy.rake
211
216
  - lib/capistrano/tasks/doctor.rake
212
217
  - lib/capistrano/tasks/framework.rake
213
- - lib/capistrano/tasks/git.rake
214
- - lib/capistrano/tasks/hg.rake
215
218
  - lib/capistrano/tasks/install.rake
216
- - lib/capistrano/tasks/svn.rake
217
219
  - lib/capistrano/templates/Capfile
218
220
  - lib/capistrano/templates/deploy.rb.erb
219
221
  - lib/capistrano/templates/stage.rb.erb
@@ -227,6 +229,7 @@ files:
227
229
  - spec/lib/capistrano/configuration/filter_spec.rb
228
230
  - spec/lib/capistrano/configuration/host_filter_spec.rb
229
231
  - spec/lib/capistrano/configuration/null_filter_spec.rb
232
+ - spec/lib/capistrano/configuration/plugin_installer_spec.rb
230
233
  - spec/lib/capistrano/configuration/question_spec.rb
231
234
  - spec/lib/capistrano/configuration/role_filter_spec.rb
232
235
  - spec/lib/capistrano/configuration/server_spec.rb
@@ -240,12 +243,12 @@ files:
240
243
  - spec/lib/capistrano/dsl/paths_spec.rb
241
244
  - spec/lib/capistrano/dsl/task_enhancements_spec.rb
242
245
  - spec/lib/capistrano/dsl_spec.rb
243
- - spec/lib/capistrano/git_spec.rb
244
- - spec/lib/capistrano/hg_spec.rb
245
246
  - spec/lib/capistrano/immutable_task_spec.rb
246
247
  - spec/lib/capistrano/plugin_spec.rb
248
+ - spec/lib/capistrano/scm/git_spec.rb
249
+ - spec/lib/capistrano/scm/hg_spec.rb
250
+ - spec/lib/capistrano/scm/svn_spec.rb
247
251
  - spec/lib/capistrano/scm_spec.rb
248
- - spec/lib/capistrano/svn_spec.rb
249
252
  - spec/lib/capistrano/upload_task_spec.rb
250
253
  - spec/lib/capistrano/version_validator_spec.rb
251
254
  - spec/lib/capistrano_spec.rb
@@ -274,12 +277,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
277
  version: '2.0'
275
278
  required_rubygems_version: !ruby/object:Gem::Requirement
276
279
  requirements:
277
- - - ">="
280
+ - - ">"
278
281
  - !ruby/object:Gem::Version
279
- version: '0'
282
+ version: 1.3.1
280
283
  requirements: []
281
284
  rubyforge_project:
282
- rubygems_version: 2.6.6
285
+ rubygems_version: 2.6.7
283
286
  signing_key:
284
287
  specification_version: 4
285
288
  summary: Capistrano - Welcome to easy deployment with Ruby over SSH
@@ -289,7 +292,6 @@ test_files:
289
292
  - features/deploy_failure.feature
290
293
  - features/doctor.feature
291
294
  - features/installation.feature
292
- - features/remote_file_task.feature
293
295
  - features/sshconnect.feature
294
296
  - features/stage_failure.feature
295
297
  - features/step_definitions/assertions.rb
@@ -305,6 +307,7 @@ test_files:
305
307
  - spec/lib/capistrano/configuration/filter_spec.rb
306
308
  - spec/lib/capistrano/configuration/host_filter_spec.rb
307
309
  - spec/lib/capistrano/configuration/null_filter_spec.rb
310
+ - spec/lib/capistrano/configuration/plugin_installer_spec.rb
308
311
  - spec/lib/capistrano/configuration/question_spec.rb
309
312
  - spec/lib/capistrano/configuration/role_filter_spec.rb
310
313
  - spec/lib/capistrano/configuration/server_spec.rb
@@ -318,12 +321,12 @@ test_files:
318
321
  - spec/lib/capistrano/dsl/paths_spec.rb
319
322
  - spec/lib/capistrano/dsl/task_enhancements_spec.rb
320
323
  - spec/lib/capistrano/dsl_spec.rb
321
- - spec/lib/capistrano/git_spec.rb
322
- - spec/lib/capistrano/hg_spec.rb
323
324
  - spec/lib/capistrano/immutable_task_spec.rb
324
325
  - spec/lib/capistrano/plugin_spec.rb
326
+ - spec/lib/capistrano/scm/git_spec.rb
327
+ - spec/lib/capistrano/scm/hg_spec.rb
328
+ - spec/lib/capistrano/scm/svn_spec.rb
325
329
  - spec/lib/capistrano/scm_spec.rb
326
- - spec/lib/capistrano/svn_spec.rb
327
330
  - spec/lib/capistrano/upload_task_spec.rb
328
331
  - spec/lib/capistrano/version_validator_spec.rb
329
332
  - spec/lib/capistrano_spec.rb
@@ -1,14 +0,0 @@
1
- Feature: Remote file task
2
-
3
- Background:
4
- Given a test app with the default configuration
5
- And a custom task to generate a file
6
- And servers with the roles app and web
7
-
8
- Scenario: Where the file does not exist
9
- When I run cap "deploy:check:linked_files"
10
- Then it creates the file with the remote_task prerequisite
11
-
12
- Scenario: Where the file already exists
13
- When I run cap "deploy:check:linked_files"
14
- Then it will not recreate the file
@@ -1,21 +0,0 @@
1
- **Important:** GitHub issues are for feature requests or bug reports. The Capistrano team recommends you use [Stack Overflow](http://stackoverflow.com/questions/tagged/capistrano) for general questions. For more details, please see our [contribution policy](https://github.com/capistrano/capistrano/blob/master/CONTRIBUTING.md).
2
-
3
- ---
4
-
5
- #### Steps to reproduce
6
-
7
- 1. Lorem.
8
- 2. Ipsum..
9
- 3. Dolor...
10
-
11
- #### Expected behaviour
12
-
13
- Tell us what should happen
14
-
15
- #### Actual behaviour
16
-
17
- Tell us what happens instead
18
-
19
- #### Your configuration
20
-
21
- Paste Capistrano's `doctor` output here (`cap <stage> doctor`):
@@ -1,54 +0,0 @@
1
- load File.expand_path("../tasks/git.rake", __FILE__)
2
-
3
- require "capistrano/scm"
4
-
5
- class Capistrano::Git < Capistrano::SCM
6
- # execute git with argument in the context
7
- #
8
- def git(*args)
9
- args.unshift :git
10
- context.execute(*args)
11
- end
12
-
13
- # The Capistrano default strategy for git. You should want to use this.
14
- module DefaultStrategy
15
- def test
16
- test! " [ -f #{repo_path}/HEAD ] "
17
- end
18
-
19
- def check
20
- git :'ls-remote --heads', repo_url
21
- end
22
-
23
- def clone
24
- if (depth = fetch(:git_shallow_clone))
25
- git :clone, "--mirror", "--depth", depth, "--no-single-branch", repo_url, repo_path
26
- else
27
- git :clone, "--mirror", repo_url, repo_path
28
- end
29
- end
30
-
31
- def update
32
- # Note: Requires git version 1.9 or greater
33
- if (depth = fetch(:git_shallow_clone))
34
- git :fetch, "--depth", depth, "origin", fetch(:branch)
35
- else
36
- git :remote, :update, "--prune"
37
- end
38
- end
39
-
40
- def release
41
- if (tree = fetch(:repo_tree))
42
- tree = tree.slice %r#^/?(.*?)/?$#, 1
43
- components = tree.split("/").size
44
- git :archive, fetch(:branch), tree, "| tar -x --strip-components #{components} -f - -C", release_path
45
- else
46
- git :archive, fetch(:branch), "| tar -x -f - -C", release_path
47
- end
48
- end
49
-
50
- def fetch_revision
51
- context.capture(:git, "rev-list --max-count=1 #{fetch(:branch)}")
52
- end
53
- end
54
- end