auto_tagger 0.1.5 → 0.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.
- data/.gitignore +4 -1
- data/CHANGELOG +26 -2
- data/Gemfile +4 -4
- data/Gemfile.lock +60 -0
- data/README.md +90 -36
- data/Rakefile +1 -26
- data/VERSION +1 -1
- data/auto_tagger.gemspec +24 -14
- data/bin/autotag +14 -29
- data/features/autotag.feature +43 -2
- data/features/deployment.feature +4 -0
- data/features/step_definitions/autotag_steps.rb +27 -22
- data/features/step_definitions/deployment_steps.rb +41 -33
- data/features/support/env.rb +45 -2
- data/features/support/step_helpers.rb +36 -12
- data/features/templates/deploy.erb +1 -1
- data/lib/auto_tagger/base.rb +150 -19
- data/lib/auto_tagger/capistrano_helper.rb +38 -17
- data/lib/auto_tagger/command_line.rb +65 -0
- data/lib/auto_tagger/commander.rb +22 -11
- data/lib/auto_tagger/configuration.rb +88 -0
- data/lib/auto_tagger/deprecator.rb +11 -0
- data/lib/auto_tagger/git/ref.rb +34 -0
- data/lib/auto_tagger/git/ref_set.rb +35 -0
- data/lib/auto_tagger/git/repo.rb +76 -0
- data/lib/auto_tagger/options.rb +170 -0
- data/lib/auto_tagger/recipes.rb +67 -27
- data/lib/auto_tagger.rb +9 -4
- data/spec/auto_tagger/base_spec.rb +236 -52
- data/spec/auto_tagger/capistrano_helper_spec.rb +82 -112
- data/spec/auto_tagger/command_line_spec.rb +110 -0
- data/spec/auto_tagger/commander_spec.rb +33 -7
- data/spec/auto_tagger/configuration_spec.rb +275 -0
- data/spec/auto_tagger/git/ref_set_spec.rb +61 -0
- data/spec/auto_tagger/git/ref_spec.rb +46 -0
- data/spec/auto_tagger/git/repo_spec.rb +108 -0
- data/spec/auto_tagger/options_spec.rb +157 -0
- data/spec/spec_helper.rb +1 -6
- metadata +32 -15
- data/geminstaller.yml +0 -7
- data/lib/auto_tagger/repository.rb +0 -43
- data/lib/auto_tagger/stage_manager.rb +0 -23
- data/lib/auto_tagger/tag.rb +0 -43
- data/spec/auto_tagger/repository_spec.rb +0 -72
- data/spec/auto_tagger/stage_manager_spec.rb +0 -34
- data/spec/auto_tagger/tag_spec.rb +0 -66
@@ -1,85 +1,269 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe AutoTagger::
|
4
|
-
|
5
|
-
|
3
|
+
describe AutoTagger::Base do
|
4
|
+
|
5
|
+
describe "#repo" do
|
6
|
+
it "returns a repo with the correct options" do
|
7
|
+
base = AutoTagger::Base.new :path => "/foo",
|
8
|
+
:dry_run => true,
|
9
|
+
:verbose => true,
|
10
|
+
:executable => "/usr/bin/git"
|
11
|
+
AutoTagger::Git::Repo.should_receive(:new).with "/foo",
|
12
|
+
:execute_commands => false,
|
13
|
+
:verbose => true,
|
14
|
+
:executable => "/usr/bin/git"
|
15
|
+
base.repo
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#last_ref_from_previous_stage" do
|
20
|
+
it "returns nil if there is no previous stage" do
|
21
|
+
refs = "0f7324495f06e2b refs/tags/ci/2001"
|
22
|
+
base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "ci"
|
23
|
+
base.repo.stub(:read).and_return(refs)
|
24
|
+
base.last_ref_from_previous_stage.should be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns nil if there are no matching refs" do
|
28
|
+
refs = "0f7324495f06e2b refs/tags-ci/2001"
|
29
|
+
base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "ci"
|
30
|
+
base.repo.stub(:read).and_return(refs)
|
31
|
+
base.last_ref_from_previous_stage.should be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return the last ref from the previous stage" do
|
35
|
+
refs = %Q{
|
36
|
+
41dee06050450ac refs/tags/ci/2003
|
37
|
+
41dee06050450a5 refs/tags/ci/2003
|
38
|
+
61c6627d766c1be refs/tags/demo/2001
|
39
|
+
}
|
40
|
+
base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "demo"
|
41
|
+
base.repo.stub(:read).and_return(refs)
|
42
|
+
ref = AutoTagger::Git::Ref.new(base.repo, "41dee06050450ac", "refs/tags/ci/2003")
|
43
|
+
base.last_ref_from_previous_stage.name.should == "refs/tags/ci/2003"
|
44
|
+
end
|
6
45
|
end
|
7
46
|
|
8
|
-
describe "
|
9
|
-
it "
|
47
|
+
describe "#create_ref" do
|
48
|
+
it "creates a ref with the given sha and returns the ref" do
|
49
|
+
base = AutoTagger::Base.new :stage => "demo"
|
50
|
+
base.stub(:timestamp).and_return("20081010")
|
51
|
+
|
52
|
+
base.repo.stub(:exec) { true }
|
53
|
+
base.repo.should_receive(:exec).with("update-ref refs/tags/demo/20081010 abc123")
|
54
|
+
|
55
|
+
ref = base.create_ref "abc123"
|
56
|
+
ref.name.should == "refs/tags/demo/20081010"
|
57
|
+
ref.sha.should == "abc123"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "defaults to the latest commit sha" do
|
61
|
+
base = AutoTagger::Base.new :stage => "demo"
|
62
|
+
base.stub(:timestamp).and_return("20081010")
|
63
|
+
|
64
|
+
base.repo.should_receive(:latest_commit_sha).and_return("abc123")
|
65
|
+
base.repo.stub(:exec) { true }
|
66
|
+
base.repo.should_receive(:exec).with("update-ref refs/tags/demo/20081010 abc123")
|
67
|
+
|
68
|
+
ref = base.create_ref
|
69
|
+
ref.name.should == "refs/tags/demo/20081010"
|
70
|
+
ref.sha.should == "abc123"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "respects the passed in date separator" do
|
74
|
+
time = Time.now.utc
|
75
|
+
timestamp = time.strftime("%Y-%m-%d-%H-%M-%S")
|
76
|
+
base = AutoTagger::Base.new :stage => "ci", :date_separator => "-"
|
77
|
+
base.repo.stub(:exec) { true }
|
78
|
+
base.repo.should_receive(:exec).with("update-ref refs/tags/ci/#{timestamp} abc123")
|
79
|
+
base.create_ref "abc123"
|
80
|
+
end
|
81
|
+
|
82
|
+
it "raises an error if the stage is not set" do
|
10
83
|
proc do
|
11
|
-
AutoTagger::
|
12
|
-
end.should raise_error(AutoTagger::
|
84
|
+
AutoTagger::Base.new({}).create_ref
|
85
|
+
end.should raise_error(AutoTagger::Base::StageCannotBeBlankError)
|
13
86
|
end
|
14
87
|
|
15
|
-
it "
|
16
|
-
AutoTagger::
|
88
|
+
it "fetches tags before creating tags" do
|
89
|
+
base = AutoTagger::Base.new :stage => "ci"
|
90
|
+
base.repo.stub(:exec) { true }
|
91
|
+
base.repo.should_receive(:exec).with("fetch origin refs/tags/*:refs/tags/*")
|
92
|
+
base.create_ref "abc123"
|
17
93
|
end
|
18
94
|
|
19
|
-
it "
|
20
|
-
|
21
|
-
|
22
|
-
|
95
|
+
it "does not fetch tags before creating tags if fetch tags is false" do
|
96
|
+
base = AutoTagger::Base.new :stage => "ci", :fetch_tags => false
|
97
|
+
base.repo.stub(:exec) { true }
|
98
|
+
base.repo.should_receive(:exec).with("push origin refs/tags/*:refs/tags/*")
|
99
|
+
base.create_ref "abc123"
|
23
100
|
end
|
24
101
|
|
25
|
-
it "
|
26
|
-
|
27
|
-
|
102
|
+
it "pushes tags before creating tags" do
|
103
|
+
base = AutoTagger::Base.new :stage => "ci"
|
104
|
+
base.repo.stub(:exec) { true }
|
105
|
+
base.repo.should_receive(:exec).with("push origin refs/tags/*:refs/tags/*")
|
106
|
+
base.create_ref "abc123"
|
28
107
|
end
|
29
108
|
|
30
|
-
it "
|
31
|
-
|
32
|
-
|
109
|
+
it "does not push tags before creating tags if push tags is false" do
|
110
|
+
base = AutoTagger::Base.new :stage => "ci", :push_tags => false
|
111
|
+
base.repo.stub(:exec) { true }
|
112
|
+
base.repo.should_receive(:exec).with("push origin refs/tags/*:refs/tags/*")
|
113
|
+
base.create_ref "abc123"
|
33
114
|
end
|
34
115
|
end
|
35
116
|
|
36
|
-
describe "#
|
37
|
-
it "
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
117
|
+
describe "#delete_locally" do
|
118
|
+
it "blows up if you don't enter a stage" do
|
119
|
+
base = AutoTagger::Base.new({})
|
120
|
+
proc do
|
121
|
+
base.delete_locally
|
122
|
+
end.should raise_error(AutoTagger::Base::StageCannotBeBlankError)
|
123
|
+
end
|
42
124
|
|
43
|
-
|
44
|
-
|
45
|
-
|
125
|
+
it "executes the local delete commands for all the refs that match" do
|
126
|
+
base = AutoTagger::Base.new :stage => "ci"
|
127
|
+
base.repo.stub(:exec) { true }
|
128
|
+
base.stub(:refs_for_stage) do
|
129
|
+
[
|
130
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008"),
|
131
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"),
|
132
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2010")
|
133
|
+
]
|
134
|
+
end
|
135
|
+
base.repo.should_receive(:exec).with("update-ref -d refs/tags/ci/2008")
|
136
|
+
base.repo.should_receive(:exec).with("update-ref -d refs/tags/ci/2009")
|
137
|
+
base.repo.should_not_receive(:exec).with("update-ref -d refs/tags/ci/2010")
|
138
|
+
base.delete_locally
|
139
|
+
end
|
140
|
+
end
|
46
141
|
|
47
|
-
|
142
|
+
describe "#delete_on_remote" do
|
143
|
+
it "blows up if you don't enter a stage" do
|
144
|
+
base = AutoTagger::Base.new({})
|
145
|
+
proc do
|
146
|
+
base.delete_on_remote
|
147
|
+
end.should raise_error(AutoTagger::Base::StageCannotBeBlankError)
|
48
148
|
end
|
49
149
|
|
50
|
-
it "
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
150
|
+
it "does not push if there are no tags" do
|
151
|
+
base = AutoTagger::Base.new :stage => "ci"
|
152
|
+
base.stub(:refs_for_stage).with("ci") {[]}
|
153
|
+
base.repo.should_not_receive(:exec)
|
154
|
+
base.delete_on_remote
|
155
|
+
end
|
55
156
|
|
56
|
-
|
57
|
-
|
58
|
-
|
157
|
+
it "executes the remote delete commands in a batch" do
|
158
|
+
base = AutoTagger::Base.new :stage => "ci"
|
159
|
+
base.repo.stub(:exec) { true }
|
160
|
+
base.stub(:refs_for_stage).with("ci") do
|
161
|
+
[
|
162
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008"),
|
163
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"),
|
164
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2010")
|
165
|
+
]
|
166
|
+
end
|
167
|
+
base.repo.should_receive(:exec).with("push origin :refs/tags/ci/2008 :refs/tags/ci/2009")
|
168
|
+
base.delete_on_remote
|
169
|
+
end
|
170
|
+
end
|
59
171
|
|
60
|
-
|
172
|
+
describe "#cleanup" do
|
173
|
+
it "blows up if you don't enter a stage" do
|
174
|
+
base = AutoTagger::Base.new({})
|
175
|
+
proc do
|
176
|
+
base.cleanup
|
177
|
+
end.should raise_error(AutoTagger::Base::StageCannotBeBlankError)
|
61
178
|
end
|
62
179
|
|
63
|
-
it "
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
180
|
+
it "executes delete locally" do
|
181
|
+
base = AutoTagger::Base.new :stage => "ci"
|
182
|
+
base.repo.stub(:exec) { true }
|
183
|
+
base.stub(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] }
|
184
|
+
base.should_receive(:delete_local_refs)
|
185
|
+
base.cleanup
|
186
|
+
end
|
69
187
|
|
70
|
-
|
188
|
+
it "executes delete on remote if push refs is true" do
|
189
|
+
base = AutoTagger::Base.new :stage => "ci"
|
190
|
+
base.repo.stub(:exec) { true }
|
191
|
+
base.stub(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] }
|
192
|
+
base.should_receive(:delete_remote_refs)
|
193
|
+
base.cleanup
|
194
|
+
end
|
195
|
+
|
196
|
+
it "does not execute delete on remote if push refs is false" do
|
197
|
+
base = AutoTagger::Base.new :stage => "ci", :offline => true
|
198
|
+
base.repo.stub(:exec) { true }
|
199
|
+
base.stub(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] }
|
200
|
+
base.should_not_receive(:delete_remote_refs)
|
201
|
+
base.cleanup
|
71
202
|
end
|
72
203
|
end
|
73
204
|
|
74
|
-
describe "
|
75
|
-
it "
|
76
|
-
|
205
|
+
describe ".items_to_remove" do
|
206
|
+
it "returns the items that can be removed from an array, based on the keep value passed in" do
|
207
|
+
AutoTagger::Base.items_to_remove(["2008"], 0).should == ["2008"]
|
208
|
+
AutoTagger::Base.items_to_remove(["2008"], 1).should == []
|
209
|
+
AutoTagger::Base.items_to_remove(["2008", "2009"], 0).should == ["2008", "2009"]
|
210
|
+
AutoTagger::Base.items_to_remove(["2008", "2009"], 1).should == ["2008"]
|
211
|
+
AutoTagger::Base.items_to_remove(["2008", "2009"], 2).should == []
|
212
|
+
AutoTagger::Base.items_to_remove(["2008", "2009"], 3).should == []
|
213
|
+
AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 0).should == ["2008", "2009", "2010"]
|
214
|
+
AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 1).should == ["2008", "2009"]
|
215
|
+
AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 2).should == ["2008"]
|
216
|
+
AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 3).should == []
|
217
|
+
end
|
218
|
+
end
|
77
219
|
|
78
|
-
|
79
|
-
|
220
|
+
describe "#refs_for_stage" do
|
221
|
+
it "returns refs that match the given stage" do
|
222
|
+
base = AutoTagger::Base.new :stage => "ci"
|
223
|
+
base.repo.stub(:exec) { true }
|
224
|
+
refs = [
|
225
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/auto_tags/ci/2008"),
|
226
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"),
|
227
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/2009"),
|
228
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags-ci/2009"),
|
229
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/heads/master")
|
230
|
+
]
|
231
|
+
base.repo.stub(:refs) { mock("RefSet", :all => refs) }
|
232
|
+
base.refs_for_stage("ci").should == [
|
233
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009")
|
234
|
+
]
|
235
|
+
end
|
236
|
+
end
|
80
237
|
|
81
|
-
|
238
|
+
describe "#list" do
|
239
|
+
it "return a list of refs for the given stage" do
|
240
|
+
base = AutoTagger::Base.new :stage => "ci"
|
241
|
+
base.should_receive(:fetch)
|
242
|
+
base.should_receive(:refs_for_stage).with("ci")
|
243
|
+
base.list
|
82
244
|
end
|
83
245
|
end
|
84
246
|
|
247
|
+
describe "#release_tag_entries" do
|
248
|
+
it "lists the last ref from each stage" do
|
249
|
+
base = AutoTagger::Base.new :stage => "ci", :stages => ["ci", "demo", "production"]
|
250
|
+
base.repo.stub(:exec) { true }
|
251
|
+
refs = [
|
252
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008"),
|
253
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"),
|
254
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/demo/2008"),
|
255
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/demo/2009"),
|
256
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2008"),
|
257
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2009")
|
258
|
+
]
|
259
|
+
base.repo.stub(:refs) { mock("RefSet", :all => refs) }
|
260
|
+
base.release_tag_entries.should == [
|
261
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"),
|
262
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/demo/2009"),
|
263
|
+
AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2009")
|
264
|
+
]
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
|
85
269
|
end
|
@@ -1,145 +1,115 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe AutoTagger::CapistranoHelper do
|
4
4
|
|
5
|
-
describe "
|
6
|
-
it "
|
7
|
-
|
8
|
-
|
9
|
-
end.should raise_error(AutoTagger::StageManager::NoStagesSpecifiedError)
|
5
|
+
describe "#ref" do
|
6
|
+
it "returns the specified branch when passed the :head variable" do
|
7
|
+
helper = AutoTagger::CapistranoHelper.new :branch => "release", :head => nil
|
8
|
+
helper.ref.should == "release"
|
10
9
|
end
|
11
|
-
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
it "returns the specified tag" do
|
12
|
+
helper = AutoTagger::CapistranoHelper.new :tag => "v0.1.7"
|
13
|
+
helper.ref.should == "v0.1.7"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the specified ref" do
|
17
|
+
helper = AutoTagger::CapistranoHelper.new :ref => "refs/auto_tags/ci"
|
18
|
+
helper.ref.should == "refs/auto_tags/ci"
|
16
19
|
end
|
17
|
-
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
AutoTagger::
|
21
|
+
it "returns the sha of the last ref from that stage" do
|
22
|
+
helper = AutoTagger::CapistranoHelper.new({})
|
23
|
+
ref = mock(AutoTagger::Git::Ref, :sha => "abc123")
|
24
|
+
auto_tagger = mock AutoTagger::Base, :last_ref_from_previous_stage => ref
|
25
|
+
helper.stub(:auto_tagger) { auto_tagger }
|
26
|
+
helper.ref.should == "abc123"
|
22
27
|
end
|
23
28
|
|
24
|
-
it "
|
25
|
-
|
26
|
-
|
29
|
+
it "returns the branch when specified" do
|
30
|
+
helper = AutoTagger::CapistranoHelper.new :branch => "release"
|
31
|
+
helper.ref.should == "release"
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
|
-
describe "#
|
31
|
-
it "returns
|
32
|
-
AutoTagger::CapistranoHelper.new({
|
33
|
-
|
35
|
+
describe "#auto_tagger" do
|
36
|
+
it "returns an AutoTagger::Base object with the correct options" do
|
37
|
+
helper = AutoTagger::CapistranoHelper.new({})
|
38
|
+
helper.stub(:auto_tagger_options).and_return({:foo => "bar"})
|
39
|
+
AutoTagger::Base.should_receive(:new).with({:foo => "bar"})
|
40
|
+
helper.auto_tagger
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
37
|
-
describe "#
|
38
|
-
it "
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
:working_directory => "/foo",
|
48
|
-
:autotagger_stages => [:ci, :staging, :production]
|
49
|
-
}
|
50
|
-
histories = AutoTagger::CapistranoHelper.new(variables).release_tag_entries
|
51
|
-
histories.length.should == 3
|
52
|
-
histories[0].should include("ci/01", "guid1")
|
53
|
-
histories[1].should include("staging/01", "guid2")
|
54
|
-
histories[2].should include("production/01", "guid3")
|
44
|
+
describe "#auto_tagger_options" do
|
45
|
+
it "includes :stage from :auto_tagger_stage, :stage" do
|
46
|
+
helper = AutoTagger::CapistranoHelper.new :stage => "demo"
|
47
|
+
helper.auto_tagger_options[:stage].should == "demo"
|
48
|
+
|
49
|
+
helper = AutoTagger::CapistranoHelper.new :auto_tagger_stage => "demo"
|
50
|
+
helper.auto_tagger_options[:stage].should == "demo"
|
51
|
+
|
52
|
+
helper = AutoTagger::CapistranoHelper.new :auto_tagger_stage => "demo", :stage => "ci"
|
53
|
+
helper.auto_tagger_options[:stage].should == "demo"
|
55
54
|
end
|
56
55
|
|
57
|
-
it "
|
58
|
-
|
59
|
-
|
60
|
-
mock(AutoTagger::Commander).execute?("/foo", "git fetch origin --tags").times(any_times) { true }
|
61
|
-
mock(File).exists?(anything).times(any_times) {true}
|
62
|
-
|
63
|
-
variables = {
|
64
|
-
:working_directory => "/foo",
|
65
|
-
:autotagger_stages => [:ci]
|
66
|
-
}
|
67
|
-
histories = AutoTagger::CapistranoHelper.new(variables).release_tag_entries
|
68
|
-
histories.length.should == 1
|
69
|
-
histories[0].should include("ci/01", "guid1")
|
56
|
+
it "includes stages" do
|
57
|
+
helper = AutoTagger::CapistranoHelper.new :auto_tagger_stages => ["demo"]
|
58
|
+
helper.auto_tagger_options[:stages].should == ["demo"]
|
70
59
|
end
|
71
|
-
end
|
72
60
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
variables = {
|
77
|
-
:autotagger_stages => [:bar],
|
78
|
-
:head => nil,
|
79
|
-
:branch => "foo"
|
80
|
-
}
|
81
|
-
AutoTagger::CapistranoHelper.new(variables).branch.should == "foo"
|
82
|
-
end
|
61
|
+
it "includes :auto_tagger_working_directory" do
|
62
|
+
helper = AutoTagger::CapistranoHelper.new :auto_tagger_working_directory => "/foo"
|
63
|
+
helper.auto_tagger_options[:path].should == "/foo"
|
83
64
|
end
|
84
65
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
:head => nil
|
90
|
-
}
|
91
|
-
AutoTagger::CapistranoHelper.new(variables).branch.should == nil
|
92
|
-
end
|
66
|
+
it "includes and deprecates :working_directory" do
|
67
|
+
AutoTagger::Deprecator.should_receive(:warn)
|
68
|
+
helper = AutoTagger::CapistranoHelper.new :working_directory => "/foo"
|
69
|
+
helper.auto_tagger_options[:path].should == "/foo"
|
93
70
|
end
|
94
71
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
72
|
+
[
|
73
|
+
:date_separator,
|
74
|
+
:push_refs,
|
75
|
+
:fetch_refs,
|
76
|
+
:remote,
|
77
|
+
:ref_path,
|
78
|
+
:offline,
|
79
|
+
:dry_run,
|
80
|
+
:verbose,
|
81
|
+
:refs_to_keep,
|
82
|
+
:executable,
|
83
|
+
:opts_file
|
84
|
+
].each do |key|
|
85
|
+
it "incudes :#{key}" do
|
86
|
+
helper = AutoTagger::CapistranoHelper.new :"auto_tagger_#{key}" => "value"
|
87
|
+
helper.auto_tagger_options[key].should == "value"
|
102
88
|
end
|
103
89
|
end
|
104
90
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
:working_directory => "/foo"
|
112
|
-
}
|
113
|
-
tagger = Object.new
|
114
|
-
mock(tagger).latest_tag { "foo_01" }
|
115
|
-
mock(AutoTagger::Runner).new("foo", "/foo") { tagger }
|
116
|
-
AutoTagger::CapistranoHelper.new(variables).branch.should == "foo_01"
|
117
|
-
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#stages" do
|
94
|
+
it "understands :stages" do
|
95
|
+
helper = AutoTagger::CapistranoHelper.new :stages => ["demo"]
|
96
|
+
helper.stages.should == ["demo"]
|
118
97
|
end
|
119
98
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
:autotagger_stages => [:foo, :bar],
|
124
|
-
:stage => :bar,
|
125
|
-
:working_directory => "/foo"
|
126
|
-
}
|
127
|
-
tagger = Object.new
|
128
|
-
mock(tagger).latest_tag { nil }
|
129
|
-
mock(AutoTagger::Runner).new("foo", "/foo") { tagger }
|
130
|
-
AutoTagger::CapistranoHelper.new(variables).branch.should == nil
|
131
|
-
end
|
99
|
+
it "understands :auto_tagger_stages" do
|
100
|
+
helper = AutoTagger::CapistranoHelper.new :auto_tagger_stages => ["demo"]
|
101
|
+
helper.auto_tagger_options[:stages].should == ["demo"]
|
132
102
|
end
|
133
103
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
104
|
+
it "understands and deprecates :autotagger_stages" do
|
105
|
+
AutoTagger::Deprecator.should_receive(:warn)
|
106
|
+
helper = AutoTagger::CapistranoHelper.new :autotagger_stages => ["demo"]
|
107
|
+
helper.stages.should == ["demo"]
|
108
|
+
end
|
109
|
+
|
110
|
+
it "makes all stages strings" do
|
111
|
+
helper = AutoTagger::CapistranoHelper.new :auto_tagger_stages => [:demo]
|
112
|
+
helper.stages.should == ["demo"]
|
143
113
|
end
|
144
114
|
end
|
145
115
|
|