capistrano 3.6.1 → 3.7.0.beta1

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.
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
@@ -1,43 +0,0 @@
1
- load File.expand_path("../tasks/hg.rake", __FILE__)
2
-
3
- require "capistrano/scm"
4
-
5
- class Capistrano::Hg < Capistrano::SCM
6
- # execute hg in context with arguments
7
- def hg(*args)
8
- args.unshift(:hg)
9
- context.execute(*args)
10
- end
11
-
12
- module DefaultStrategy
13
- def test
14
- test! " [ -d #{repo_path}/.hg ] "
15
- end
16
-
17
- def check
18
- hg "id", repo_url
19
- end
20
-
21
- def clone
22
- hg "clone", "--noupdate", repo_url, repo_path
23
- end
24
-
25
- def update
26
- hg "pull"
27
- end
28
-
29
- def release
30
- if (tree = fetch(:repo_tree))
31
- tree = tree.slice %r#^/?(.*?)/?$#, 1
32
- components = tree.split("/").size
33
- hg "archive --type tgz -p . -I", tree, "--rev", fetch(:branch), "| tar -x --strip-components #{components} -f - -C", release_path
34
- else
35
- hg "archive", release_path, "--rev", fetch(:branch)
36
- end
37
- end
38
-
39
- def fetch_revision
40
- context.capture(:hg, "log --rev #{fetch(:branch)} --template \"{node}\n\"")
41
- end
42
- end
43
- end
@@ -1,42 +0,0 @@
1
- load File.expand_path("../tasks/svn.rake", __FILE__)
2
-
3
- require "capistrano/scm"
4
-
5
- class Capistrano::Svn < Capistrano::SCM
6
- # execute svn in context with arguments
7
- def svn(*args)
8
- args.unshift(:svn)
9
- args.push "--username #{fetch(:svn_username)}" if fetch(:svn_username)
10
- args.push "--password #{fetch(:svn_password)}" if fetch(:svn_password)
11
- args.push "--revision #{fetch(:svn_revision)}" if fetch(:svn_revision)
12
- context.execute(*args)
13
- end
14
-
15
- module DefaultStrategy
16
- def test
17
- test! " [ -d #{repo_path}/.svn ] "
18
- end
19
-
20
- def check
21
- svn_username = fetch(:svn_username) ? "--username #{fetch(:svn_username)}" : ""
22
- svn_password = fetch(:svn_password) ? "--password #{fetch(:svn_password)}" : ""
23
- test! :svn, :info, repo_url, svn_username, svn_password
24
- end
25
-
26
- def clone
27
- svn :checkout, repo_url, repo_path
28
- end
29
-
30
- def update
31
- svn :update
32
- end
33
-
34
- def release
35
- svn :export, "--force", ".", release_path
36
- end
37
-
38
- def fetch_revision
39
- context.capture(:svnversion, repo_path)
40
- end
41
- end
42
- end
@@ -1,109 +0,0 @@
1
- require "spec_helper"
2
-
3
- require "capistrano/git"
4
-
5
- module Capistrano
6
- describe Git do
7
- let(:context) { Class.new.new }
8
- subject { Capistrano::Git.new(context, Capistrano::Git::DefaultStrategy) }
9
-
10
- describe "#git" do
11
- it "should call execute git in the context, with arguments" do
12
- context.expects(:execute).with(:git, :init)
13
- subject.git(:init)
14
- end
15
- end
16
- end
17
-
18
- describe Git::DefaultStrategy do
19
- let(:context) { Class.new.new }
20
- subject { Capistrano::Git.new(context, Capistrano::Git::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 " [ -f /path/to/repo/HEAD ] "
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(:execute).with(:git, :'ls-remote --heads', :url).returns(true)
35
-
36
- subject.check
37
- end
38
- end
39
-
40
- describe "#clone" do
41
- it "should run git clone" do
42
- context.expects(:fetch).with(:git_shallow_clone).returns(nil)
43
- context.expects(:repo_url).returns(:url)
44
- context.expects(:repo_path).returns(:path)
45
- context.expects(:execute).with(:git, :clone, "--mirror", :url, :path)
46
-
47
- subject.clone
48
- end
49
-
50
- it "should run git clone in shallow mode" do
51
- context.expects(:fetch).with(:git_shallow_clone).returns("1")
52
- context.expects(:repo_url).returns(:url)
53
- context.expects(:repo_path).returns(:path)
54
-
55
- context.expects(:execute).with(:git, :clone, "--mirror", "--depth", "1", "--no-single-branch", :url, :path)
56
-
57
- subject.clone
58
- end
59
- end
60
-
61
- describe "#update" do
62
- it "should run git update" do
63
- context.expects(:fetch).with(:git_shallow_clone).returns(nil)
64
- context.expects(:execute).with(:git, :remote, :update, "--prune")
65
-
66
- subject.update
67
- end
68
-
69
- it "should run git update in shallow mode" do
70
- context.expects(:fetch).with(:git_shallow_clone).returns("1")
71
- context.expects(:fetch).with(:branch).returns(:branch)
72
- context.expects(:execute).with(:git, :fetch, "--depth", "1", "origin", :branch)
73
-
74
- subject.update
75
- end
76
- end
77
-
78
- describe "#release" do
79
- it "should run git archive without a subtree" do
80
- context.expects(:fetch).with(:repo_tree).returns(nil)
81
- context.expects(:fetch).with(:branch).returns(:branch)
82
- context.expects(:release_path).returns(:path)
83
-
84
- context.expects(:execute).with(:git, :archive, :branch, "| tar -x -f - -C", :path)
85
-
86
- subject.release
87
- end
88
-
89
- it "should run git archive with a subtree" do
90
- context.expects(:fetch).with(:repo_tree).returns("tree")
91
- context.expects(:fetch).with(:branch).returns(:branch)
92
- context.expects(:release_path).returns(:path)
93
-
94
- context.expects(:execute).with(:git, :archive, :branch, "tree", "| tar -x --strip-components 1 -f - -C", :path)
95
-
96
- subject.release
97
- end
98
- end
99
-
100
- describe "#fetch_revision" do
101
- it "should capture git rev-list" do
102
- context.expects(:fetch).with(:branch).returns(:branch)
103
- context.expects(:capture).with(:git, "rev-list --max-count=1 branch").returns("81cec13b777ff46348693d327fc8e7832f79bf43")
104
- revision = subject.fetch_revision
105
- expect(revision).to eq("81cec13b777ff46348693d327fc8e7832f79bf43")
106
- end
107
- end
108
- end
109
- end
@@ -1,90 +0,0 @@
1
- require "spec_helper"
2
-
3
- require "capistrano/hg"
4
-
5
- module Capistrano
6
- describe Hg do
7
- let(:context) { Class.new.new }
8
- subject { Capistrano::Hg.new(context, Capistrano::Hg::DefaultStrategy) }
9
-
10
- describe "#hg" do
11
- it "should call execute hg in the context, with arguments" do
12
- context.expects(:execute).with(:hg, :init)
13
- subject.hg(:init)
14
- end
15
- end
16
- end
17
-
18
- describe Hg::DefaultStrategy do
19
- let(:context) { Class.new.new }
20
- subject { Capistrano::Hg.new(context, Capistrano::Hg::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/.hg ] "
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(:execute).with(:hg, "id", :url)
35
-
36
- subject.check
37
- end
38
- end
39
-
40
- describe "#clone" do
41
- it "should run hg clone" do
42
- context.expects(:repo_url).returns(:url)
43
- context.expects(:repo_path).returns(:path)
44
-
45
- context.expects(:execute).with(:hg, "clone", "--noupdate", :url, :path)
46
-
47
- subject.clone
48
- end
49
- end
50
-
51
- describe "#update" do
52
- it "should run hg update" do
53
- context.expects(:execute).with(:hg, "pull")
54
-
55
- subject.update
56
- end
57
- end
58
-
59
- describe "#release" do
60
- it "should run hg archive without a subtree" do
61
- context.expects(:fetch).with(:repo_tree).returns(nil)
62
- context.expects(:fetch).with(:branch).returns(:branch)
63
- context.expects(:release_path).returns(:path)
64
-
65
- context.expects(:execute).with(:hg, "archive", :path, "--rev", :branch)
66
-
67
- subject.release
68
- end
69
-
70
- it "should run hg archive with a subtree" do
71
- context.expects(:fetch).with(:repo_tree).returns("tree")
72
- context.expects(:fetch).with(:branch).returns(:branch)
73
- context.expects(:release_path).returns(:path)
74
-
75
- context.expects(:execute).with(:hg, "archive --type tgz -p . -I", "tree", "--rev", :branch, "| tar -x --strip-components 1 -f - -C", :path)
76
-
77
- subject.release
78
- end
79
- end
80
-
81
- describe "#fetch_revision" do
82
- it "should capture hg log" do
83
- context.expects(:fetch).with(:branch).returns(:branch)
84
- context.expects(:capture).with(:hg, "log --rev branch --template \"{node}\n\"").returns("01abcde")
85
- revision = subject.fetch_revision
86
- expect(revision).to eq("01abcde")
87
- end
88
- end
89
- end
90
- end
@@ -1,105 +0,0 @@
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, "--username someuser", "--password somepassword")
13
- context.expects(:fetch).twice.with(:svn_username).returns("someuser")
14
- context.expects(:fetch).twice.with(:svn_password).returns("somepassword")
15
- context.expects(:fetch).once.with(:svn_revision).returns(nil)
16
- subject.svn(:init)
17
- end
18
- end
19
- end
20
-
21
- describe Svn::DefaultStrategy do
22
- let(:context) { Class.new.new }
23
- subject { Capistrano::Svn.new(context, Capistrano::Svn::DefaultStrategy) }
24
-
25
- describe "#test" do
26
- it "should call test for repo HEAD" do
27
- context.expects(:repo_path).returns("/path/to/repo")
28
- context.expects(:test).with " [ -d /path/to/repo/.svn ] "
29
-
30
- subject.test
31
- end
32
- end
33
-
34
- describe "#check" do
35
- it "should test the repo url" do
36
- context.expects(:repo_url).returns(:url)
37
- context.expects(:test).with(:svn, :info, :url, "--username someuser", "--password somepassword").returns(true)
38
- context.expects(:fetch).twice.with(:svn_username).returns("someuser")
39
- context.expects(:fetch).twice.with(:svn_password).returns("somepassword")
40
-
41
- subject.check
42
- end
43
- end
44
-
45
- describe "#clone" do
46
- it "should run svn checkout" do
47
- context.expects(:repo_url).returns(:url)
48
- context.expects(:repo_path).returns(:path)
49
- context.expects(:fetch).twice.with(:svn_username).returns("someuser")
50
- context.expects(:fetch).twice.with(:svn_password).returns("somepassword")
51
- context.expects(:fetch).once.with(:svn_revision).returns(nil)
52
-
53
- context.expects(:execute).with(:svn, :checkout, :url, :path, "--username someuser", "--password somepassword")
54
-
55
- subject.clone
56
- end
57
- end
58
-
59
- describe "#update" do
60
- it "should run svn update" do
61
- context.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
62
- context.expects(:fetch).twice.with(:svn_username).returns("someuser")
63
- context.expects(:fetch).twice.with(:svn_password).returns("somepassword")
64
- context.expects(:fetch).once.with(:svn_revision).returns(nil)
65
-
66
- subject.update
67
- end
68
- end
69
-
70
- describe "#update_specific_revision" do
71
- it "should run svn update and update to a specific revision" do
72
- context.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword", "--revision 12345")
73
- context.expects(:fetch).twice.with(:svn_username).returns("someuser")
74
- context.expects(:fetch).twice.with(:svn_password).returns("somepassword")
75
- context.expects(:fetch).twice.with(:svn_revision).returns("12345")
76
-
77
- subject.update
78
- end
79
- end
80
-
81
- describe "#release" do
82
- it "should run svn export" do
83
- context.expects(:release_path).returns(:path)
84
- context.expects(:fetch).twice.with(:svn_username).returns("someuser")
85
- context.expects(:fetch).twice.with(:svn_password).returns("somepassword")
86
- context.expects(:fetch).once.with(:svn_revision).returns(nil)
87
-
88
- context.expects(:execute).with(:svn, :export, "--force", ".", :path, "--username someuser", "--password somepassword")
89
-
90
- subject.release
91
- end
92
- end
93
-
94
- describe "#fetch_revision" do
95
- it "should capture svn version" do
96
- context.expects(:repo_path).returns(:path)
97
-
98
- context.expects(:capture).with(:svnversion, :path).returns("12345")
99
-
100
- revision = subject.fetch_revision
101
- expect(revision).to eq("12345")
102
- end
103
- end
104
- end
105
- end