mixlib-versioning 1.0.0 → 1.2.12
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/lib/mixlib/versioning.rb +41 -37
- data/lib/mixlib/versioning/exceptions.rb +2 -2
- data/lib/mixlib/versioning/format.rb +42 -38
- data/lib/mixlib/versioning/format/git_describe.rb +5 -7
- data/lib/mixlib/versioning/format/opscode_semver.rb +8 -19
- data/lib/mixlib/versioning/format/partial_semver.rb +62 -0
- data/lib/mixlib/versioning/format/rubygems.rb +14 -10
- data/lib/mixlib/versioning/format/semver.rb +9 -11
- data/lib/mixlib/versioning/version.rb +3 -3
- metadata +15 -87
- data/.gitignore +0 -18
- data/.yardopts +0 -7
- data/CHANGELOG.md +0 -3
- data/CONTRIBUTING.md +0 -188
- data/Gemfile +0 -9
- data/README.md +0 -364
- data/Rakefile +0 -6
- data/mixlib-versioning.gemspec +0 -22
- data/spec/mixlib/versioning/format/git_describe_spec.rb +0 -178
- data/spec/mixlib/versioning/format/opscode_semver_spec.rb +0 -113
- data/spec/mixlib/versioning/format/rubygems_spec.rb +0 -142
- data/spec/mixlib/versioning/format/semver_spec.rb +0 -107
- data/spec/mixlib/versioning/format_spec.rb +0 -69
- data/spec/mixlib/versioning/versioning_spec.rb +0 -259
- data/spec/spec_helper.rb +0 -43
- data/spec/support/shared_examples/basic_semver.rb +0 -42
- data/spec/support/shared_examples/behaviors/filterable.rb +0 -66
- data/spec/support/shared_examples/behaviors/parses_valid_version_strings.rb +0 -32
- data/spec/support/shared_examples/behaviors/rejects_invalid_version_strings.rb +0 -32
- data/spec/support/shared_examples/behaviors/serializable.rb +0 -51
- data/spec/support/shared_examples/behaviors/sortable.rb +0 -45
- data/spec/support/shared_examples/semver.rb +0 -105
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,364 +0,0 @@
|
|
1
|
-
# Mixlib::Versioning
|
2
|
-
|
3
|
-
Versioning is hard! `mixlib-versioning` is a general Ruby library that allows
|
4
|
-
you to parse, compare and manipulate version numbers in multiple formats.
|
5
|
-
Currently the following version string formats are supported:
|
6
|
-
|
7
|
-
### SemVer 2.0.0-rc.1
|
8
|
-
|
9
|
-
**Specification:**
|
10
|
-
|
11
|
-
http://semver.org/
|
12
|
-
|
13
|
-
**Supported Formats:**
|
14
|
-
|
15
|
-
```text
|
16
|
-
MAJOR.MINOR.PATCH
|
17
|
-
MAJOR.MINOR.PATCH-PRERELEASE
|
18
|
-
MAJOR.MINOR.PATCH-PRERELEASE+BUILD
|
19
|
-
```
|
20
|
-
|
21
|
-
Not much to say here except: *YUNO USE SEMVER!* The specification is focused and
|
22
|
-
brief, do yourself a favor and go read it.
|
23
|
-
|
24
|
-
### Opscode SemVer
|
25
|
-
|
26
|
-
**Supported Formats:**
|
27
|
-
|
28
|
-
```text
|
29
|
-
MAJOR.MINOR.PATCH
|
30
|
-
MAJOR.MINOR.PATCH-alpha.INDEX
|
31
|
-
MAJOR.MINOR.PATCH-beta.INDEX
|
32
|
-
MAJOR.MINOR.PATCH-rc.INDEX
|
33
|
-
MAJOR.MINOR.PATCH-alpha.INDEX+YYYYMMDDHHMMSS
|
34
|
-
MAJOR.MINOR.PATCH-beta.INDEX+YYYYMMDDHHMMSS
|
35
|
-
MAJOR.MINOR.PATCH-rc.INDEX+YYYYMMDDHHMMSS
|
36
|
-
MAJOR.MINOR.PATCH-alpha.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1
|
37
|
-
MAJOR.MINOR.PATCH-beta.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1
|
38
|
-
MAJOR.MINOR.PATCH-rc.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1
|
39
|
-
```
|
40
|
-
|
41
|
-
All the fun of regular SemVer with some extra limits around what constitutes a
|
42
|
-
valid pre-release or build version string.
|
43
|
-
|
44
|
-
Valid prerelease version strings use the format: `PRERELEASE_STAGE.INDEX`.
|
45
|
-
Valid prerelease stages include: `alpha`, `beta` and `rc`.
|
46
|
-
|
47
|
-
All of the following are acceptable Opscode SemVer pre-release versions:
|
48
|
-
|
49
|
-
```text
|
50
|
-
11.0.8-alpha.0
|
51
|
-
11.0.8-alpha.1
|
52
|
-
11.0.8-beta.7
|
53
|
-
11.0.8-beta.8
|
54
|
-
11.0.8-rc.1
|
55
|
-
11.0.8-rc.2
|
56
|
-
```
|
57
|
-
|
58
|
-
Build version strings are limited to timestamps (`YYYYMMDDHHMMSS`), git
|
59
|
-
describe strings (`git.COMMITS_SINCE.SHA1`) or a combination of the two
|
60
|
-
(`YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1`).
|
61
|
-
|
62
|
-
All of the following are acceptable Opscode build versions:
|
63
|
-
|
64
|
-
```text
|
65
|
-
11.0.8+20130308110833
|
66
|
-
11.0.8+git.2.g94a1dde
|
67
|
-
11.0.8+20130308110833.git.2.94a1dde
|
68
|
-
```
|
69
|
-
|
70
|
-
And as is true with regular SemVer you can mix pre-release and build versions:
|
71
|
-
|
72
|
-
```text
|
73
|
-
11.0.8-rc.1+20130308110833
|
74
|
-
11.0.8-alpha.2+20130308110833.git.2.94a1dde
|
75
|
-
```
|
76
|
-
|
77
|
-
### Rubygems
|
78
|
-
|
79
|
-
**specification:**
|
80
|
-
|
81
|
-
http://docs.rubygems.org/read/chapter/7
|
82
|
-
|
83
|
-
http://guides.rubygems.org/patterns/
|
84
|
-
|
85
|
-
**Supported Formats:**
|
86
|
-
|
87
|
-
```text
|
88
|
-
MAJOR.MINOR.PATCH
|
89
|
-
MAJOR.MINOR.PATCH.PRERELEASE
|
90
|
-
```
|
91
|
-
|
92
|
-
Rubygems is *almost* SemVer compliant but it separates the main version from
|
93
|
-
the pre-release version using a "dot". It also does not have the notion of a
|
94
|
-
build version like SemVer.
|
95
|
-
|
96
|
-
Examples of valid Rubygems version strings:
|
97
|
-
|
98
|
-
```text
|
99
|
-
10.1.1
|
100
|
-
10.1.1
|
101
|
-
10.1.1.alpha.1
|
102
|
-
10.1.1.beta.1
|
103
|
-
10.1.1.rc.0
|
104
|
-
```
|
105
|
-
|
106
|
-
### Git Describe
|
107
|
-
|
108
|
-
**Specification:**
|
109
|
-
|
110
|
-
http://git-scm.com/docs/git-describe
|
111
|
-
|
112
|
-
**Supported Formats:**
|
113
|
-
|
114
|
-
```text
|
115
|
-
MAJOR.MINOR.PATCH-COMMITS_SINCE-gGIT_SHA1
|
116
|
-
MAJOR.MINOR.PATCH-COMMITS_SINCE-gGIT_SHA1-ITERATION
|
117
|
-
MAJOR.MINOR.PATCH-PRERELEASE-COMMITS_SINCE-gGIT_SHA1
|
118
|
-
MAJOR.MINOR.PATCH-PRERELEASE-COMMITS_SINCE-gGIT_SHA1-ITERATION
|
119
|
-
```
|
120
|
-
|
121
|
-
Examples of valid Git Describe version strings:
|
122
|
-
|
123
|
-
```text
|
124
|
-
10.16.2-49-g21353f0-1
|
125
|
-
10.16.2.rc.1-49-g21353f0-1
|
126
|
-
11.0.0-alpha-10-g642ffed
|
127
|
-
11.0.0-alpha.1-1-gcea071e
|
128
|
-
```
|
129
|
-
|
130
|
-
## Installation
|
131
|
-
|
132
|
-
Add this line to your application's Gemfile:
|
133
|
-
|
134
|
-
gem 'mixlib-versioning'
|
135
|
-
|
136
|
-
And then execute:
|
137
|
-
|
138
|
-
$ bundle
|
139
|
-
|
140
|
-
Or install it yourself as:
|
141
|
-
|
142
|
-
$ gem install mixlib-semver
|
143
|
-
|
144
|
-
## Usage
|
145
|
-
|
146
|
-
### Basic Version String Parsing
|
147
|
-
|
148
|
-
```irb
|
149
|
-
>> require 'mixlib/versioning'
|
150
|
-
true
|
151
|
-
>> v1 = Mixlib::Versioning.parse("11.0.3")
|
152
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3fecddccff4c @major=11, @minor=0, @patch=3, @prerelease=nil, @build=nil, @input="11.0.3">
|
153
|
-
>> v1.release?
|
154
|
-
true
|
155
|
-
>> v1.prerelease?
|
156
|
-
false
|
157
|
-
>> v1.build?
|
158
|
-
false
|
159
|
-
>> v1.prerelease_build?
|
160
|
-
false
|
161
|
-
>> v2 = Mixlib::Versioning.parse("11.0.0-beta.1")
|
162
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3fecde44f420 @major=11, @minor=0, @patch=0, @prerelease="beta.1", @build=nil, @input="11.0.0-beta.1">
|
163
|
-
>> v2.release?
|
164
|
-
false
|
165
|
-
>> v2.prerelease?
|
166
|
-
true
|
167
|
-
>> v2.build?
|
168
|
-
false
|
169
|
-
>> v2.prerelease_build?
|
170
|
-
false
|
171
|
-
>> v3 = Mixlib::Versioning.parse("11.0.6+20130216075209")
|
172
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3fecde49568c @major=11, @minor=0, @patch=6, @prerelease=nil, @build="20130216075209", @input="11.0.6+20130216075209">
|
173
|
-
>> v3.release?
|
174
|
-
false
|
175
|
-
>> v3.prerelease?
|
176
|
-
false
|
177
|
-
>> v3.build?
|
178
|
-
true
|
179
|
-
>> v3.prerelease_build?
|
180
|
-
false
|
181
|
-
>> v4 = Mixlib::Versioning.parse("11.0.8-rc.1+20130302083119")
|
182
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3fecde4dad7c @major=11, @minor=0, @patch=8, @prerelease="rc.1", @build="20130302083119", @input="11.0.8-rc.1+20130302083119">
|
183
|
-
>> v4.release?
|
184
|
-
false
|
185
|
-
>> v4.prerelease?
|
186
|
-
false
|
187
|
-
>> v4.build?
|
188
|
-
true
|
189
|
-
>> v4.prerelease_build?
|
190
|
-
true
|
191
|
-
>> v5 = Mixlib::Versioning.parse("10.16.8.alpha.0")
|
192
|
-
#<Mixlib::Versioning::Format::Rubygems:0x3fecde532bd0 @major=10, @minor=16, @patch=8, @prerelease="alpha.0", @iteration=0, @input="10.16.8.alpha.0">
|
193
|
-
>> v5.major
|
194
|
-
10
|
195
|
-
>> v5.minor
|
196
|
-
16
|
197
|
-
>> v5.patch
|
198
|
-
8
|
199
|
-
>> v5.prerelease
|
200
|
-
"alpha.0"
|
201
|
-
>> v5.release?
|
202
|
-
false
|
203
|
-
>> v5.prerelease?
|
204
|
-
true
|
205
|
-
```
|
206
|
-
|
207
|
-
### Version Comparison and Sorting
|
208
|
-
|
209
|
-
```irb
|
210
|
-
>> require 'mixlib/versioning'
|
211
|
-
true
|
212
|
-
>> v1 = Mixlib::Versioning.parse("11.0.0-beta.1")
|
213
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009cd54e0 @major=11, @minor=0, @patch=0, @prerelease="beta.1", @build=nil, @input="11.0.0-beta.1">
|
214
|
-
>> v2 = Mixlib::Versioning.parse("11.0.0-rc.1")
|
215
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009d07260 @major=11, @minor=0, @patch=0, @prerelease="rc.1", @build=nil, @input="11.0.0-rc.1">
|
216
|
-
>> v3 = Mixlib::Versioning.parse("11.0.0")
|
217
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009d0d3cc @major=11, @minor=0, @patch=0, @prerelease=nil, @build=nil, @input="11.0.0">
|
218
|
-
>> v1 < v2
|
219
|
-
true
|
220
|
-
>> v3 < v1
|
221
|
-
false
|
222
|
-
>> v1 == v2
|
223
|
-
false
|
224
|
-
>> [v3, v1, v2].sort
|
225
|
-
[
|
226
|
-
[0] #<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009cd54e0 @major=11, @minor=0, @patch=0, @prerelease="beta.1", @build=nil, @input="11.0.0-beta.1">,
|
227
|
-
[1] #<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009d07260 @major=11, @minor=0, @patch=0, @prerelease="rc.1", @build=nil, @input="11.0.0-rc.1">,
|
228
|
-
[2] #<Mixlib::Versioning::Format::OpscodeSemVer:0x3ff009d0d3cc @major=11, @minor=0, @patch=0, @prerelease=nil, @build=nil, @input="11.0.0">
|
229
|
-
]
|
230
|
-
>> [v3, v1, v2].map{|v| v.to_s}.sort
|
231
|
-
[
|
232
|
-
[0] "11.0.0",
|
233
|
-
[1] "11.0.0-beta.1",
|
234
|
-
[2] "11.0.0-rc.1"
|
235
|
-
]
|
236
|
-
```
|
237
|
-
|
238
|
-
### Target Version Selection
|
239
|
-
|
240
|
-
Basic usage:
|
241
|
-
|
242
|
-
```ruby
|
243
|
-
>> require 'mixlib/versioning'
|
244
|
-
true
|
245
|
-
>> all_versions = %w{
|
246
|
-
11.0.0-alpha.1
|
247
|
-
11.0.0-alpha.1-1-gcea071e
|
248
|
-
11.0.0-alpha.3+20130103213604.git.11.3fe70b5
|
249
|
-
11.0.0-alpha.3+20130129075201.git.38.3332a80
|
250
|
-
11.0.0-alpha.3+20130130075202.git.38.3332a80
|
251
|
-
11.0.0-beta.0+20130131044557
|
252
|
-
11.0.0-beta.1+20130201023059.git.5.c9d3320
|
253
|
-
11.0.0-beta.2+20130201035911
|
254
|
-
11.0.0-beta.2+20130201191308.git.4.9aa4cb2
|
255
|
-
11.0.0-rc.1
|
256
|
-
11.0.0+20130204053034.git.1.1802643
|
257
|
-
11.0.4
|
258
|
-
11.0.6-alpha.0+20130208045134.git.2.298c401
|
259
|
-
11.0.6-alpha.0+20130214075209.git.11.5d72e1c
|
260
|
-
11.0.6-alpha.0+20130215075208.git.11.5d72e1c
|
261
|
-
11.0.6-rc.0
|
262
|
-
11.0.6
|
263
|
-
11.0.6+20130216075209
|
264
|
-
11.0.6+20130221075213
|
265
|
-
11.0.8-rc.1
|
266
|
-
11.0.8-rc.1+20130302083119
|
267
|
-
11.0.8-rc.1+20130304083118
|
268
|
-
11.0.8-rc.1+20130305083118
|
269
|
-
11.0.8-rc.1+20130305195925.git.2.94a1dde
|
270
|
-
11.0.8-rc.1+20130306083036.git.2.94a1dde
|
271
|
-
11.0.8-rc.1+20130319083111.git.6.dc8613e
|
272
|
-
};''
|
273
|
-
""
|
274
|
-
>> Mixlib::Versioning.find_target_version(all_versions, "11.0.6", false, false)
|
275
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ffdc91364a4 @major=11, @minor=0, @patch=6, @prerelease=nil, @build=nil, @input="11.0.6">
|
276
|
-
>> target = Mixlib::Versioning.find_target_version(all_versions, "11.0.6", false, false)
|
277
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ffdc91364a4 @major=11, @minor=0, @patch=6, @prerelease=nil, @build=nil, @input="11.0.6">
|
278
|
-
>> target.to_s
|
279
|
-
"11.0.6"
|
280
|
-
```
|
281
|
-
|
282
|
-
Select latest release version:
|
283
|
-
|
284
|
-
```irb
|
285
|
-
>> target = Mixlib::Versioning.find_target_version(all_versions, nil, false, false)
|
286
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ffdc91364a4 @major=11, @minor=0, @patch=6, @prerelease=nil, @build=nil, @input="11.0.6">
|
287
|
-
>> target.to_s
|
288
|
-
"11.0.6"
|
289
|
-
```
|
290
|
-
|
291
|
-
Select latest pre-release version:
|
292
|
-
|
293
|
-
```irb
|
294
|
-
>> target = Mixlib::Versioning.find_target_version(all_versions, nil, true, false)
|
295
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ffdc9139078 @major=11, @minor=0, @patch=8, @prerelease="rc.1", @build=nil, @input="11.0.8-rc.1">
|
296
|
-
>> target.to_s
|
297
|
-
"11.0.8-rc.1"
|
298
|
-
```
|
299
|
-
|
300
|
-
Select the latest release build version:
|
301
|
-
|
302
|
-
```irb
|
303
|
-
>> target = Mixlib::Versioning.find_target_version(all_versions, nil, false, true)
|
304
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ffdc91f0bb0 @major=11, @minor=0, @patch=6, @prerelease=nil, @build="20130221075213", @input="11.0.6+20130221075213">
|
305
|
-
>> target.to_s
|
306
|
-
"11.0.6+20130221075213"
|
307
|
-
```
|
308
|
-
|
309
|
-
Select the latest pre-release build version:
|
310
|
-
|
311
|
-
```irb
|
312
|
-
>> target = Mixlib::Versioning.find_target_version(all_versions, nil, true, true)
|
313
|
-
#<Mixlib::Versioning::Format::OpscodeSemVer:0x3ffdc91f154c @major=11, @minor=0, @patch=8, @prerelease="rc.1", @build="20130319083111.git.6.dc8613e", @input="11.0.8-rc.1+20130319083111.git.6.dc8613e">
|
314
|
-
>> target.to_s
|
315
|
-
"11.0.8-rc.1+20130319083111.git.6.dc8613e"
|
316
|
-
```
|
317
|
-
|
318
|
-
## How to Run the Tests
|
319
|
-
|
320
|
-
To run the unit tests, run
|
321
|
-
|
322
|
-
```
|
323
|
-
rake spec
|
324
|
-
```
|
325
|
-
|
326
|
-
## Documentation
|
327
|
-
|
328
|
-
All documentation is written using YARD. You can generate a by running:
|
329
|
-
|
330
|
-
```
|
331
|
-
rake yard
|
332
|
-
```
|
333
|
-
|
334
|
-
## Contributing
|
335
|
-
|
336
|
-
See the [CONTRIBUTING](CONTRIBUTING.md) document.
|
337
|
-
|
338
|
-
## Reporting Bugs
|
339
|
-
|
340
|
-
You can search for known issues in [Opscode's bug tracker][jira]. Tickets
|
341
|
-
should be filed under the **MIXLIB** project with the component set to
|
342
|
-
**"mixlib-versioning"**.
|
343
|
-
|
344
|
-
## License
|
345
|
-
|
346
|
-
| | |
|
347
|
-
|:---------------------|:-----------------------------------------|
|
348
|
-
| **Author:** | Seth Chisamore (schisamo@opscode.com)
|
349
|
-
| **Copyright:** | Copyright (c) 2013 Opscode, Inc.
|
350
|
-
| **License:** | Apache License, Version 2.0
|
351
|
-
|
352
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
353
|
-
you may not use this file except in compliance with the License.
|
354
|
-
You may obtain a copy of the License at
|
355
|
-
|
356
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
357
|
-
|
358
|
-
Unless required by applicable law or agreed to in writing, software
|
359
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
360
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
361
|
-
See the License for the specific language governing permissions and
|
362
|
-
limitations under the License.
|
363
|
-
|
364
|
-
[jira]: http://tickets.opscode.com/browse/MIXLIB
|
data/Rakefile
DELETED
data/mixlib-versioning.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'mixlib/versioning/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "mixlib-versioning"
|
8
|
-
gem.version = Mixlib::Versioning::VERSION
|
9
|
-
gem.authors = ["Seth Chisamore", "Christopher Maier"]
|
10
|
-
gem.email = ["schisamo@opscode.com", "cm@opscode.com"]
|
11
|
-
gem.description = "General purpose Ruby library that allows you to parse, compare and manipulate version strings in multiple formats."
|
12
|
-
gem.summary = gem.description
|
13
|
-
gem.homepage = "https://github.com/opscode/mixlib-versioning"
|
14
|
-
|
15
|
-
gem.add_development_dependency "rspec"
|
16
|
-
gem.add_development_dependency "rspec_junit_formatter"
|
17
|
-
|
18
|
-
gem.files = `git ls-files`.split($/)
|
19
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
-
gem.require_paths = ["lib"]
|
22
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Seth Chisamore (<schisamo@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'spec_helper'
|
20
|
-
|
21
|
-
describe Mixlib::Versioning::Format::GitDescribe do
|
22
|
-
|
23
|
-
subject{ described_class.new(version_string) }
|
24
|
-
|
25
|
-
it_has_behavior "parses valid version strings", {
|
26
|
-
"0.10.8-231-g59d6185" => {
|
27
|
-
:major => 0,
|
28
|
-
:minor => 10,
|
29
|
-
:patch => 8,
|
30
|
-
:prerelease => nil,
|
31
|
-
:build => "231.g59d6185.0",
|
32
|
-
:release? => false,
|
33
|
-
:prerelease? => false,
|
34
|
-
:build? => true,
|
35
|
-
:release_build? => true,
|
36
|
-
:prerelease_build? => false,
|
37
|
-
:commits_since => 231,
|
38
|
-
:commit_sha => "59d6185",
|
39
|
-
:iteration => 0
|
40
|
-
},
|
41
|
-
"10.16.2-49-g21353f0-1" => {
|
42
|
-
:major => 10,
|
43
|
-
:minor => 16,
|
44
|
-
:patch => 2,
|
45
|
-
:prerelease => nil,
|
46
|
-
:build => "49.g21353f0.1",
|
47
|
-
:release? => false,
|
48
|
-
:prerelease? => false,
|
49
|
-
:build? => true,
|
50
|
-
:release_build? => true,
|
51
|
-
:prerelease_build? => false,
|
52
|
-
:commits_since => 49,
|
53
|
-
:commit_sha => "21353f0",
|
54
|
-
:iteration => 1
|
55
|
-
},
|
56
|
-
"10.16.2.rc.1-49-g21353f0-1" => {
|
57
|
-
:major => 10,
|
58
|
-
:minor => 16,
|
59
|
-
:patch => 2,
|
60
|
-
:prerelease => "rc.1",
|
61
|
-
:build => "49.g21353f0.1",
|
62
|
-
:release? => false,
|
63
|
-
:prerelease? => false,
|
64
|
-
:build? => true,
|
65
|
-
:release_build? => false,
|
66
|
-
:prerelease_build? => true,
|
67
|
-
:commits_since => 49,
|
68
|
-
:commit_sha => "21353f0",
|
69
|
-
:iteration => 1
|
70
|
-
},
|
71
|
-
"10.16.2-alpha-49-g21353f0-1" => {
|
72
|
-
:major => 10,
|
73
|
-
:minor => 16,
|
74
|
-
:patch => 2,
|
75
|
-
:prerelease => "alpha",
|
76
|
-
:build => "49.g21353f0.1",
|
77
|
-
:release? => false,
|
78
|
-
:prerelease? => false,
|
79
|
-
:build? => true,
|
80
|
-
:release_build? => false,
|
81
|
-
:prerelease_build? => true,
|
82
|
-
:commits_since => 49,
|
83
|
-
:commit_sha => "21353f0",
|
84
|
-
:iteration => 1
|
85
|
-
},
|
86
|
-
"10.16.2-alpha-49-g21353f0" => {
|
87
|
-
:major => 10,
|
88
|
-
:minor => 16,
|
89
|
-
:patch => 2,
|
90
|
-
:prerelease => "alpha",
|
91
|
-
:build => "49.g21353f0.0",
|
92
|
-
:release? => false,
|
93
|
-
:prerelease? => false,
|
94
|
-
:build? => true,
|
95
|
-
:release_build? => false,
|
96
|
-
:prerelease_build? => true,
|
97
|
-
:commits_since => 49,
|
98
|
-
:commit_sha => "21353f0",
|
99
|
-
:iteration => 0
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
it_has_behavior "rejects invalid version strings", {
|
104
|
-
"1.0.0" => "no git describe data",
|
105
|
-
"1.0.0-alpha.1" => "no git describe data",
|
106
|
-
"1.0.0-alpha.1+build.deadbeef" => "no git describe data",
|
107
|
-
"1.0.0-123-gfd0e3a65282cb5f6df3bab6a53f4fcb722340d499-1" => "too many SHA1 characters",
|
108
|
-
"1.0.0-123-gdeadbe-1" => "too few SHA1 characters",
|
109
|
-
"1.0.0-123-gNOTHEX1-1" => "illegal SHA1 characters",
|
110
|
-
"1.0.0-123-g1234567-alpha" => "non-numeric iteration",
|
111
|
-
"1.0.0-alpha-poop-g1234567-1" => "non-numeric 'commits_since'",
|
112
|
-
"1.0.0-g1234567-1" => "missing 'commits_since'",
|
113
|
-
"1.0.0-123-1" => "missing SHA1"
|
114
|
-
}
|
115
|
-
|
116
|
-
version_strings = %w{
|
117
|
-
9.0.1-1-gdeadbee-1
|
118
|
-
9.1.2-2-g1234567-1
|
119
|
-
10.0.0-1-gabcdef3-1
|
120
|
-
10.5.7-2-g21353f0-1
|
121
|
-
10.20.2-2-gbbbbbbb-1
|
122
|
-
10.20.2-3-gaaaaaaa-1
|
123
|
-
9.0.1-2-gdeadbe1-1
|
124
|
-
9.0.1-2-gdeadbe1-2
|
125
|
-
9.0.1-2-gdeadbe2-1
|
126
|
-
9.1.1-2-g1234567-1
|
127
|
-
}
|
128
|
-
|
129
|
-
it_has_behavior "serializable", version_strings
|
130
|
-
|
131
|
-
it_has_behavior "sortable" do
|
132
|
-
let(:unsorted_version_strings){ version_strings }
|
133
|
-
let(:sorted_version_strings){%w{
|
134
|
-
9.0.1-1-gdeadbee-1
|
135
|
-
9.0.1-2-gdeadbe1-1
|
136
|
-
9.0.1-2-gdeadbe1-2
|
137
|
-
9.0.1-2-gdeadbe2-1
|
138
|
-
9.1.1-2-g1234567-1
|
139
|
-
9.1.2-2-g1234567-1
|
140
|
-
10.0.0-1-gabcdef3-1
|
141
|
-
10.5.7-2-g21353f0-1
|
142
|
-
10.20.2-2-gbbbbbbb-1
|
143
|
-
10.20.2-3-gaaaaaaa-1
|
144
|
-
}}
|
145
|
-
let(:min){ "9.0.1-1-gdeadbee-1" }
|
146
|
-
let(:max){ "10.20.2-3-gaaaaaaa-1" }
|
147
|
-
end # it_has_behavior
|
148
|
-
|
149
|
-
# The +GitDescribe+ format only produces release build versions.
|
150
|
-
it_has_behavior "filterable" do
|
151
|
-
let(:unsorted_version_strings){ version_strings }
|
152
|
-
let(:build_versions){%w{
|
153
|
-
9.0.1-1-gdeadbee-1
|
154
|
-
9.1.2-2-g1234567-1
|
155
|
-
10.0.0-1-gabcdef3-1
|
156
|
-
10.5.7-2-g21353f0-1
|
157
|
-
10.20.2-2-gbbbbbbb-1
|
158
|
-
10.20.2-3-gaaaaaaa-1
|
159
|
-
9.0.1-2-gdeadbe1-1
|
160
|
-
9.0.1-2-gdeadbe1-2
|
161
|
-
9.0.1-2-gdeadbe2-1
|
162
|
-
9.1.1-2-g1234567-1
|
163
|
-
}}
|
164
|
-
let(:release_build_versions){%w{
|
165
|
-
9.0.1-1-gdeadbee-1
|
166
|
-
9.1.2-2-g1234567-1
|
167
|
-
10.0.0-1-gabcdef3-1
|
168
|
-
10.5.7-2-g21353f0-1
|
169
|
-
10.20.2-2-gbbbbbbb-1
|
170
|
-
10.20.2-3-gaaaaaaa-1
|
171
|
-
9.0.1-2-gdeadbe1-1
|
172
|
-
9.0.1-2-gdeadbe1-2
|
173
|
-
9.0.1-2-gdeadbe2-1
|
174
|
-
9.1.1-2-g1234567-1
|
175
|
-
}}
|
176
|
-
end # it_has_behavior
|
177
|
-
|
178
|
-
end # describe
|