piko-fast-tool 0.0.1
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 +7 -0
- data/capistrano-3.20.1/CHANGELOG.md +1 -0
- data/capistrano-3.20.1/CONTRIBUTING.md +63 -0
- data/capistrano-3.20.1/DEVELOPMENT.md +112 -0
- data/capistrano-3.20.1/Gemfile +9 -0
- data/capistrano-3.20.1/LICENSE.txt +21 -0
- data/capistrano-3.20.1/README.md +221 -0
- data/capistrano-3.20.1/RELEASING.md +17 -0
- data/capistrano-3.20.1/Rakefile +24 -0
- data/capistrano-3.20.1/UPGRADING-3.7.md +86 -0
- data/capistrano-3.20.1/bin/cap +3 -0
- data/capistrano-3.20.1/bin/capify +8 -0
- data/capistrano-3.20.1/capistrano.gemspec +34 -0
- data/capistrano-3.20.1/docker-compose.yml +8 -0
- data/capistrano-3.20.1/features/configuration.feature +28 -0
- data/capistrano-3.20.1/features/deploy.feature +92 -0
- data/capistrano-3.20.1/features/deploy_failure.feature +17 -0
- data/capistrano-3.20.1/features/doctor.feature +11 -0
- data/capistrano-3.20.1/features/installation.feature +21 -0
- data/capistrano-3.20.1/features/sshconnect.feature +11 -0
- data/capistrano-3.20.1/features/stage_failure.feature +9 -0
- data/capistrano-3.20.1/features/step_definitions/assertions.rb +162 -0
- data/capistrano-3.20.1/features/step_definitions/cap_commands.rb +21 -0
- data/capistrano-3.20.1/features/step_definitions/setup.rb +91 -0
- data/capistrano-3.20.1/features/subdirectory.feature +9 -0
- data/capistrano-3.20.1/features/support/docker_gateway.rb +53 -0
- data/capistrano-3.20.1/features/support/env.rb +1 -0
- data/capistrano-3.20.1/features/support/remote_command_helpers.rb +29 -0
- data/capistrano-3.20.1/features/support/remote_ssh_helpers.rb +33 -0
- data/capistrano-3.20.1/gemfiles/legacy.gemfile +7 -0
- data/capistrano-3.20.1/lib/Capfile +3 -0
- data/capistrano-3.20.1/lib/capistrano/all.rb +17 -0
- data/capistrano-3.20.1/lib/capistrano/application.rb +153 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/filter.rb +26 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/host_filter.rb +29 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/null_filter.rb +9 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/plugin_installer.rb +51 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/question.rb +76 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/role_filter.rb +29 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/scm_resolver.rb +149 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/server.rb +135 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/servers.rb +76 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/validated_variables.rb +110 -0
- data/capistrano-3.20.1/lib/capistrano/configuration/variables.rb +112 -0
- data/capistrano-3.20.1/lib/capistrano/configuration.rb +189 -0
- data/capistrano-3.20.1/lib/capistrano/console.rb +1 -0
- data/capistrano-3.20.1/lib/capistrano/defaults.rb +36 -0
- data/capistrano-3.20.1/lib/capistrano/deploy.rb +3 -0
- data/capistrano-3.20.1/lib/capistrano/doctor/environment_doctor.rb +19 -0
- data/capistrano-3.20.1/lib/capistrano/doctor/gems_doctor.rb +45 -0
- data/capistrano-3.20.1/lib/capistrano/doctor/output_helpers.rb +79 -0
- data/capistrano-3.20.1/lib/capistrano/doctor/servers_doctor.rb +105 -0
- data/capistrano-3.20.1/lib/capistrano/doctor/variables_doctor.rb +74 -0
- data/capistrano-3.20.1/lib/capistrano/doctor.rb +6 -0
- data/capistrano-3.20.1/lib/capistrano/dotfile.rb +2 -0
- data/capistrano-3.20.1/lib/capistrano/dsl/env.rb +43 -0
- data/capistrano-3.20.1/lib/capistrano/dsl/paths.rb +89 -0
- data/capistrano-3.20.1/lib/capistrano/dsl/stages.rb +31 -0
- data/capistrano-3.20.1/lib/capistrano/dsl/task_enhancements.rb +61 -0
- data/capistrano-3.20.1/lib/capistrano/dsl.rb +95 -0
- data/capistrano-3.20.1/lib/capistrano/framework.rb +2 -0
- data/capistrano-3.20.1/lib/capistrano/i18n.rb +46 -0
- data/capistrano-3.20.1/lib/capistrano/immutable_task.rb +30 -0
- data/capistrano-3.20.1/lib/capistrano/install.rb +1 -0
- data/capistrano-3.20.1/lib/capistrano/plugin.rb +95 -0
- data/capistrano-3.20.1/lib/capistrano/proc_helpers.rb +13 -0
- data/capistrano-3.20.1/lib/capistrano/scm/git.rb +106 -0
- data/capistrano-3.20.1/lib/capistrano/scm/hg.rb +55 -0
- data/capistrano-3.20.1/lib/capistrano/scm/plugin.rb +13 -0
- data/capistrano-3.20.1/lib/capistrano/scm/svn.rb +56 -0
- data/capistrano-3.20.1/lib/capistrano/scm/tasks/git.rake +84 -0
- data/capistrano-3.20.1/lib/capistrano/scm/tasks/hg.rake +53 -0
- data/capistrano-3.20.1/lib/capistrano/scm/tasks/svn.rake +53 -0
- data/capistrano-3.20.1/lib/capistrano/scm.rb +115 -0
- data/capistrano-3.20.1/lib/capistrano/setup.rb +36 -0
- data/capistrano-3.20.1/lib/capistrano/tasks/console.rake +25 -0
- data/capistrano-3.20.1/lib/capistrano/tasks/deploy.rake +280 -0
- data/capistrano-3.20.1/lib/capistrano/tasks/doctor.rake +24 -0
- data/capistrano-3.20.1/lib/capistrano/tasks/framework.rake +67 -0
- data/capistrano-3.20.1/lib/capistrano/tasks/install.rake +41 -0
- data/capistrano-3.20.1/lib/capistrano/templates/Capfile +38 -0
- data/capistrano-3.20.1/lib/capistrano/templates/deploy.rb.erb +39 -0
- data/capistrano-3.20.1/lib/capistrano/templates/stage.rb.erb +61 -0
- data/capistrano-3.20.1/lib/capistrano/upload_task.rb +9 -0
- data/capistrano-3.20.1/lib/capistrano/version.rb +3 -0
- data/capistrano-3.20.1/lib/capistrano/version_validator.rb +32 -0
- data/capistrano-3.20.1/lib/capistrano.rb +0 -0
- data/capistrano-3.20.1/spec/integration/dsl_spec.rb +632 -0
- data/capistrano-3.20.1/spec/integration_spec_helper.rb +5 -0
- data/capistrano-3.20.1/spec/lib/capistrano/application_spec.rb +60 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/question_spec.rb +92 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/server_spec.rb +309 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
- data/capistrano-3.20.1/spec/lib/capistrano/configuration_spec.rb +357 -0
- data/capistrano-3.20.1/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/capistrano-3.20.1/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
- data/capistrano-3.20.1/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/capistrano-3.20.1/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
- data/capistrano-3.20.1/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
- data/capistrano-3.20.1/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
- data/capistrano-3.20.1/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
- data/capistrano-3.20.1/spec/lib/capistrano/dsl_spec.rb +125 -0
- data/capistrano-3.20.1/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/capistrano-3.20.1/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/capistrano-3.20.1/spec/lib/capistrano/scm/git_spec.rb +194 -0
- data/capistrano-3.20.1/spec/lib/capistrano/scm/hg_spec.rb +109 -0
- data/capistrano-3.20.1/spec/lib/capistrano/scm/svn_spec.rb +137 -0
- data/capistrano-3.20.1/spec/lib/capistrano/scm_spec.rb +103 -0
- data/capistrano-3.20.1/spec/lib/capistrano/upload_task_spec.rb +19 -0
- data/capistrano-3.20.1/spec/lib/capistrano/version_validator_spec.rb +118 -0
- data/capistrano-3.20.1/spec/lib/capistrano_spec.rb +7 -0
- data/capistrano-3.20.1/spec/spec_helper.rb +29 -0
- data/capistrano-3.20.1/spec/support/matchers.rb +5 -0
- data/capistrano-3.20.1/spec/support/tasks/database.rake +11 -0
- data/capistrano-3.20.1/spec/support/tasks/fail.rake +8 -0
- data/capistrano-3.20.1/spec/support/tasks/failed.rake +5 -0
- data/capistrano-3.20.1/spec/support/tasks/plugin.rake +6 -0
- data/capistrano-3.20.1/spec/support/tasks/root.rake +11 -0
- data/capistrano-3.20.1/spec/support/test_app.rb +205 -0
- data/piko-fast-tool.gemspec +11 -0
- metadata +167 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
require "capistrano/scm/git"
|
|
4
|
+
|
|
5
|
+
module Capistrano
|
|
6
|
+
describe SCM::Git do
|
|
7
|
+
subject { Capistrano::SCM::Git.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
|
+
Rake::Task.define_task("deploy:set_current_revision_time")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Clean up any tasks or variables that the plugin defined.
|
|
26
|
+
after do
|
|
27
|
+
Rake::Task.clear
|
|
28
|
+
Capistrano::Configuration.reset!
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "#set_defaults" do
|
|
32
|
+
it "makes git_wrapper_path using a random hex value" do
|
|
33
|
+
env.set(:tmp_dir, "/tmp")
|
|
34
|
+
subject.set_defaults
|
|
35
|
+
expect(env.fetch(:git_wrapper_path)).to match(%r{/tmp/git-ssh-\h{20}\.sh})
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "makes git_max_concurrent_connections" do
|
|
39
|
+
subject.set_defaults
|
|
40
|
+
expect(env.fetch(:git_max_concurrent_connections)).to eq(10)
|
|
41
|
+
env.set(:git_max_concurrent_connections, 7)
|
|
42
|
+
expect(env.fetch(:git_max_concurrent_connections)).to eq(7)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "makes git_wait_interval" do
|
|
46
|
+
subject.set_defaults
|
|
47
|
+
expect(env.fetch(:git_wait_interval)).to eq(0)
|
|
48
|
+
env.set(:git_wait_interval, 5)
|
|
49
|
+
expect(env.fetch(:git_wait_interval)).to eq(5)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "#git" do
|
|
54
|
+
it "should call execute git in the context, with arguments" do
|
|
55
|
+
backend.expects(:execute).with(:git, :init)
|
|
56
|
+
subject.git(:init)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "#repo_mirror_exists?" do
|
|
61
|
+
it "should call test for repo HEAD" do
|
|
62
|
+
env.set(:repo_path, "/path/to/repo")
|
|
63
|
+
backend.expects(:test).with " [ -f /path/to/repo/HEAD ] "
|
|
64
|
+
|
|
65
|
+
subject.repo_mirror_exists?
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "#check_repo_is_reachable" do
|
|
70
|
+
it "should test the repo url" do
|
|
71
|
+
env.set(:repo_url, "url")
|
|
72
|
+
backend.expects(:execute).with(:git, :'ls-remote', "url", "HEAD").returns(true)
|
|
73
|
+
|
|
74
|
+
subject.check_repo_is_reachable
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "#clone_repo" do
|
|
79
|
+
it "should run git clone" do
|
|
80
|
+
env.set(:repo_url, "url")
|
|
81
|
+
env.set(:repo_path, "path")
|
|
82
|
+
backend.expects(:execute).with(:git, :clone, "--mirror", "url", "path")
|
|
83
|
+
|
|
84
|
+
subject.clone_repo
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should run git clone in shallow mode" do
|
|
88
|
+
env.set(:git_shallow_clone, "1")
|
|
89
|
+
env.set(:repo_url, "url")
|
|
90
|
+
env.set(:repo_path, "path")
|
|
91
|
+
|
|
92
|
+
backend.expects(:execute).with(:git, :clone, "--mirror", "--depth", "1", "--no-single-branch", "url", "path")
|
|
93
|
+
|
|
94
|
+
subject.clone_repo
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context "with username and password specified" do
|
|
98
|
+
before do
|
|
99
|
+
env.set(:git_http_username, "hello")
|
|
100
|
+
env.set(:git_http_password, "topsecret")
|
|
101
|
+
env.set(:repo_url, "https://example.com/repo.git")
|
|
102
|
+
env.set(:repo_path, "path")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should include the credentials in the url" do
|
|
106
|
+
backend.expects(:execute).with(:git, :clone, "--mirror", "https://hello:topsecret@example.com/repo.git", "path")
|
|
107
|
+
subject.clone_repo
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe "#update_mirror" do
|
|
113
|
+
it "should run git update" do
|
|
114
|
+
env.set(:repo_url, "url")
|
|
115
|
+
|
|
116
|
+
backend.expects(:execute).with(:git, :remote, "set-url", "origin", "url")
|
|
117
|
+
backend.expects(:execute).with(:git, :remote, :update, "--prune")
|
|
118
|
+
|
|
119
|
+
subject.update_mirror
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "should run git update in shallow mode" do
|
|
123
|
+
env.set(:git_shallow_clone, "1")
|
|
124
|
+
env.set(:branch, "branch")
|
|
125
|
+
env.set(:repo_url, "url")
|
|
126
|
+
|
|
127
|
+
backend.expects(:execute).with(:git, :remote, "set-url", "origin", "url")
|
|
128
|
+
backend.expects(:execute).with(:git, :fetch, "--depth", "1", "origin", "branch")
|
|
129
|
+
|
|
130
|
+
subject.update_mirror
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe "#archive_to_release_path" do
|
|
135
|
+
it "should run git archive without a subtree" do
|
|
136
|
+
env.set(:branch, "branch")
|
|
137
|
+
env.set(:release_path, "path")
|
|
138
|
+
|
|
139
|
+
backend.expects(:execute).with(:git, :archive, "branch", "| /usr/bin/env tar -x -f - -C", "path")
|
|
140
|
+
|
|
141
|
+
subject.archive_to_release_path
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "should run git archive with a subtree" do
|
|
145
|
+
env.set(:repo_tree, "tree")
|
|
146
|
+
env.set(:branch, "branch")
|
|
147
|
+
env.set(:release_path, "path")
|
|
148
|
+
|
|
149
|
+
backend.expects(:execute).with(:git, :archive, "branch", "tree", "| /usr/bin/env tar -x --strip-components 1 -f - -C", "path")
|
|
150
|
+
|
|
151
|
+
subject.archive_to_release_path
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should run tar with an overridden name" do
|
|
155
|
+
env.set(:branch, "branch")
|
|
156
|
+
env.set(:release_path, "path")
|
|
157
|
+
SSHKit.config.command_map.expects(:[]).with(:tar).returns("/usr/bin/env gtar")
|
|
158
|
+
|
|
159
|
+
backend.expects(:execute).with(:git, :archive, "branch", "| /usr/bin/env gtar -x -f - -C", "path")
|
|
160
|
+
|
|
161
|
+
subject.archive_to_release_path
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
describe "#fetch_revision" do
|
|
166
|
+
it "should capture git rev-list" do
|
|
167
|
+
env.set(:branch, "branch")
|
|
168
|
+
backend.expects(:capture).with(:git, "rev-list --max-count=1 branch").returns("81cec13b777ff46348693d327fc8e7832f79bf43")
|
|
169
|
+
revision = subject.fetch_revision
|
|
170
|
+
expect(revision).to eq("81cec13b777ff46348693d327fc8e7832f79bf43")
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
describe "#fetch_revision_time" do
|
|
175
|
+
it "should capture git log without a pager" do
|
|
176
|
+
env.set(:branch, "branch")
|
|
177
|
+
backend.expects(:capture).with(:git, "--no-pager log -1 --pretty=format:\"%ct\" branch").returns("1715828406")
|
|
178
|
+
revision_time = subject.fetch_revision_time
|
|
179
|
+
expect(revision_time).to eq("1715828406")
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe "#verify_commit" do
|
|
184
|
+
it "should run git verify-commit" do
|
|
185
|
+
env.set(:branch, "branch")
|
|
186
|
+
|
|
187
|
+
backend.expects(:capture).with(:git, "rev-list --max-count=1 branch").returns("81cec13b777ff46348693d327fc8e7832f79bf43")
|
|
188
|
+
backend.expects(:execute).with(:git, :"verify-commit", "81cec13b777ff46348693d327fc8e7832f79bf43")
|
|
189
|
+
|
|
190
|
+
subject.verify_commit
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
env.set(:tmp_dir, "/tmp")
|
|
89
|
+
|
|
90
|
+
SecureRandom.stubs(:hex).with(10).returns("random")
|
|
91
|
+
backend.expects(:execute).with(:hg, "archive -p . -I", "tree", "--rev", :branch, "/tmp/random.tar")
|
|
92
|
+
backend.expects(:execute).with(:mkdir, "-p", "path")
|
|
93
|
+
backend.expects(:execute).with(:tar, "-x --strip-components 1 -f", "/tmp/random.tar", "-C", "path")
|
|
94
|
+
backend.expects(:execute).with(:rm, "/tmp/random.tar")
|
|
95
|
+
|
|
96
|
+
subject.archive_to_release_path
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe "#fetch_revision" do
|
|
101
|
+
it "should capture hg log" do
|
|
102
|
+
env.set(:branch, :branch)
|
|
103
|
+
backend.expects(:capture).with(:hg, "log --rev branch --template \"{node}\n\"").returns("01abcde")
|
|
104
|
+
revision = subject.fetch_revision
|
|
105
|
+
expect(revision).to eq("01abcde")
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
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(:repo_url, "url")
|
|
75
|
+
env.set(:repo_path, "path")
|
|
76
|
+
backend.expects(:capture).with(:svn, :info, "path").returns("URL: url\n")
|
|
77
|
+
|
|
78
|
+
env.set(:svn_username, "someuser")
|
|
79
|
+
env.set(:svn_password, "somepassword")
|
|
80
|
+
backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
|
|
81
|
+
|
|
82
|
+
subject.update_mirror
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "for specific revision" do
|
|
86
|
+
it "should run svn update" do
|
|
87
|
+
env.set(:repo_url, "url")
|
|
88
|
+
env.set(:repo_path, "path")
|
|
89
|
+
backend.expects(:capture).with(:svn, :info, "path").returns("URL: url\n")
|
|
90
|
+
|
|
91
|
+
env.set(:svn_username, "someuser")
|
|
92
|
+
env.set(:svn_password, "somepassword")
|
|
93
|
+
env.set(:svn_revision, "12345")
|
|
94
|
+
backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword", "--revision 12345")
|
|
95
|
+
|
|
96
|
+
subject.update_mirror
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should run svn switch if repo_url is changed" do
|
|
101
|
+
env.set(:repo_url, "url")
|
|
102
|
+
env.set(:repo_path, "path")
|
|
103
|
+
backend.expects(:capture).with(:svn, :info, "path").returns("URL: old_url\n")
|
|
104
|
+
|
|
105
|
+
env.set(:svn_username, "someuser")
|
|
106
|
+
env.set(:svn_password, "somepassword")
|
|
107
|
+
backend.expects(:execute).with(:svn, :switch, "url", "--username someuser", "--password somepassword")
|
|
108
|
+
backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
|
|
109
|
+
|
|
110
|
+
subject.update_mirror
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "#archive_to_release_path" do
|
|
115
|
+
it "should run svn export" do
|
|
116
|
+
env.set(:release_path, "path")
|
|
117
|
+
env.set(:svn_username, "someuser")
|
|
118
|
+
env.set(:svn_password, "somepassword")
|
|
119
|
+
|
|
120
|
+
backend.expects(:execute).with(:svn, :export, "--force", ".", "path", "--username someuser", "--password somepassword")
|
|
121
|
+
|
|
122
|
+
subject.archive_to_release_path
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe "#fetch_revision" do
|
|
127
|
+
it "should capture svn version" do
|
|
128
|
+
env.set(:repo_path, "path")
|
|
129
|
+
|
|
130
|
+
backend.expects(:capture).with(:svnversion, "path").returns("12345")
|
|
131
|
+
|
|
132
|
+
revision = subject.fetch_revision
|
|
133
|
+
expect(revision).to eq("12345")
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
require "capistrano/scm"
|
|
4
|
+
|
|
5
|
+
module RaiseNotImplementedMacro
|
|
6
|
+
def raise_not_implemented_on(method)
|
|
7
|
+
it "should raise NotImplemented on #{method}" do
|
|
8
|
+
expect do
|
|
9
|
+
subject.send(method)
|
|
10
|
+
end.to raise_error(NotImplementedError)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RSpec.configure do
|
|
16
|
+
include RaiseNotImplementedMacro
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module DummyStrategy
|
|
20
|
+
def test
|
|
21
|
+
test!("you dummy!")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
module BlindStrategy; end
|
|
26
|
+
|
|
27
|
+
module Capistrano
|
|
28
|
+
describe SCM do
|
|
29
|
+
let(:context) { mock }
|
|
30
|
+
|
|
31
|
+
describe "#initialize" do
|
|
32
|
+
subject { Capistrano::SCM.new(context, DummyStrategy) }
|
|
33
|
+
|
|
34
|
+
it "should load the provided strategy" do
|
|
35
|
+
context.expects(:test).with("you dummy!")
|
|
36
|
+
subject.test
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "Convenience methods" do
|
|
41
|
+
subject { Capistrano::SCM.new(context, BlindStrategy) }
|
|
42
|
+
|
|
43
|
+
describe "#test!" do
|
|
44
|
+
it "should return call test on the context" do
|
|
45
|
+
context.expects(:test).with(:x)
|
|
46
|
+
subject.test!(:x)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "#repo_url" do
|
|
51
|
+
it "should return the repo url according to the context" do
|
|
52
|
+
context.expects(:repo_url).returns(:url)
|
|
53
|
+
expect(subject.repo_url).to eq(:url)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "#repo_path" do
|
|
58
|
+
it "should return the repo path according to the context" do
|
|
59
|
+
context.expects(:repo_path).returns(:path)
|
|
60
|
+
expect(subject.repo_path).to eq(:path)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "#release_path" do
|
|
65
|
+
it "should return the release path according to the context" do
|
|
66
|
+
context.expects(:release_path).returns("/path/to/nowhere")
|
|
67
|
+
expect(subject.release_path).to eq("/path/to/nowhere")
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#fetch" do
|
|
72
|
+
it "should call fetch on the context" do
|
|
73
|
+
context.expects(:fetch)
|
|
74
|
+
subject.fetch(:branch)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe "With a 'blind' strategy" do
|
|
80
|
+
subject { Capistrano::SCM.new(context, BlindStrategy) }
|
|
81
|
+
|
|
82
|
+
describe "#test" do
|
|
83
|
+
raise_not_implemented_on(:test)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "#check" do
|
|
87
|
+
raise_not_implemented_on(:check)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "#clone" do
|
|
91
|
+
raise_not_implemented_on(:clone)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "#update" do
|
|
95
|
+
raise_not_implemented_on(:update)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "#release" do
|
|
99
|
+
raise_not_implemented_on(:release)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Capistrano::UploadTask do
|
|
4
|
+
let(:app) { Rake.application = Rake::Application.new }
|
|
5
|
+
|
|
6
|
+
subject(:upload_task) { described_class.define_task("path/file.yml") }
|
|
7
|
+
|
|
8
|
+
it { is_expected.to be_a(Rake::FileCreationTask) }
|
|
9
|
+
it { is_expected.to be_needed }
|
|
10
|
+
|
|
11
|
+
context "inside namespace" do
|
|
12
|
+
let(:normal_task) { Rake::Task.define_task("path/other_file.yml") }
|
|
13
|
+
|
|
14
|
+
around { |ex| app.in_namespace("namespace", &ex) }
|
|
15
|
+
|
|
16
|
+
it { expect(upload_task.name).to eq("path/file.yml") }
|
|
17
|
+
it { expect(upload_task.scope.path).to eq("namespace") }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Capistrano
|
|
4
|
+
describe VersionValidator do
|
|
5
|
+
let(:validator) { VersionValidator.new(version) }
|
|
6
|
+
let(:version) { stub }
|
|
7
|
+
|
|
8
|
+
describe "#new" do
|
|
9
|
+
it "takes a version" do
|
|
10
|
+
expect(validator)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#verify" do
|
|
15
|
+
let(:current_version) { "3.0.1" }
|
|
16
|
+
|
|
17
|
+
subject { validator.verify }
|
|
18
|
+
|
|
19
|
+
before do
|
|
20
|
+
validator.stubs(:current_version).returns(current_version)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "with exact version" do
|
|
24
|
+
context "valid" do
|
|
25
|
+
let(:version) { "3.0.1" }
|
|
26
|
+
it { expect(subject).to be_truthy }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "invalid - lower" do
|
|
30
|
+
let(:version) { "3.0.0" }
|
|
31
|
+
|
|
32
|
+
it "fails" do
|
|
33
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "invalid - higher" do
|
|
38
|
+
let(:version) { "3.0.2" }
|
|
39
|
+
|
|
40
|
+
it "fails" do
|
|
41
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "with optimistic versioning" do
|
|
47
|
+
context "valid" do
|
|
48
|
+
let(:version) { ">= 3.0.0" }
|
|
49
|
+
it { expect(subject).to be_truthy }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "invalid - lower" do
|
|
53
|
+
let(:version) { "<= 2.0.0" }
|
|
54
|
+
|
|
55
|
+
it "fails" do
|
|
56
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context "with pessimistic versioning" do
|
|
62
|
+
context "2 decimal places" do
|
|
63
|
+
context "valid" do
|
|
64
|
+
let(:version) { "~> 3.0.0" }
|
|
65
|
+
it { expect(subject).to be_truthy }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "invalid" do
|
|
69
|
+
let(:version) { "~> 3.1.0" }
|
|
70
|
+
|
|
71
|
+
it "fails" do
|
|
72
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "1 decimal place" do
|
|
78
|
+
let(:current_version) { "3.5.0" }
|
|
79
|
+
|
|
80
|
+
context "valid" do
|
|
81
|
+
let(:version) { "~> 3.1" }
|
|
82
|
+
it { expect(subject).to be_truthy }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "invalid" do
|
|
86
|
+
let(:version) { "~> 3.6" }
|
|
87
|
+
it "fails" do
|
|
88
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "with multiple versions" do
|
|
94
|
+
let(:current_version) { "3.5.9" }
|
|
95
|
+
|
|
96
|
+
context "valid" do
|
|
97
|
+
let(:version) { [">= 3.5.0", "< 3.5.10"] }
|
|
98
|
+
it { is_expected.to be_truthy }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
context "invalid" do
|
|
102
|
+
let(:version) { [">= 3.5.0", "< 3.5.8"] }
|
|
103
|
+
it "fails" do
|
|
104
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context "invalid" do
|
|
109
|
+
let(:version) { ["> 3.5.9", "< 3.5.13"] }
|
|
110
|
+
it "fails" do
|
|
111
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|