knife-changelog 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/knife/changelog/version.rb +1 -1
- data/lib/policyfile.rb +16 -1
- data/spec/unit/policyfile_spec.rb +24 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6427a7cfa99765ab6a02df18e9695630b841647d09844d8ac56b72a6bb1dfb6a
|
4
|
+
data.tar.gz: f44ddf5ff9e5f5be024ee151d76e547c08dd4d7245a837c63142d493b1a6ce80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c285457809139a674fe3337aaba0d462adeab532209bdc4a6fc73f88d4d11775c83e873869ea99ac132408cf9401c1d535e829026a0f600e37625bce1ee95209
|
7
|
+
data.tar.gz: d009ca6842b5e0974978fe6b0e4759cebb8bae8351343dd72f3e88363591f8ef7dd5ec98a0016fc88df276f32173b36b818f8cfbc6df88cbd77aa8afd4a54012
|
data/lib/policyfile.rb
CHANGED
@@ -145,7 +145,22 @@ class PolicyChangelog
|
|
145
145
|
# @param repo [Git::Base] Git repository object
|
146
146
|
# @return [String] Git tag versioning type
|
147
147
|
def tag_format(repo)
|
148
|
-
repo.tags.last.name[/^v/] ? 'v' : ''
|
148
|
+
sort_by_version(repo.tags).last.name[/^v/] ? 'v' : ''
|
149
|
+
end
|
150
|
+
|
151
|
+
# Sort tags by version and filter out invalid version tags
|
152
|
+
#
|
153
|
+
# @param tags [Array<Git::Object::Tag>] git tags
|
154
|
+
# @return [Array] git tags sorted by version
|
155
|
+
def sort_by_version(tags)
|
156
|
+
tags.sort_by do |t|
|
157
|
+
begin
|
158
|
+
Gem::Version.new(t.name.gsub(/^v/, ''))
|
159
|
+
rescue ArgumentError => e
|
160
|
+
# Skip tag if version is not valid (i.e. a String)
|
161
|
+
Gem::Version.new(nil) if e.to_s.include?('Malformed version number string')
|
162
|
+
end
|
163
|
+
end
|
149
164
|
end
|
150
165
|
|
151
166
|
# Formats commit changelog to be more readable
|
@@ -40,6 +40,18 @@ RSpec.describe PolicyChangelog do
|
|
40
40
|
|
41
41
|
let(:url) { 'https://supermarket.chef.io/api/v1/cookbooks/users' }
|
42
42
|
|
43
|
+
let(:tags) do
|
44
|
+
[
|
45
|
+
double(name: '1.0.0'),
|
46
|
+
double(name: '0.9.1'),
|
47
|
+
double(name: 'v1.0.5'),
|
48
|
+
double(name: 'v1.1.1'),
|
49
|
+
double(name: 'invalid'),
|
50
|
+
double(name: '5.2.1'),
|
51
|
+
double(name: 'v0.1.1')
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
43
55
|
before(:each) do
|
44
56
|
stub_request(:get, 'https://supermarket.chef.io/api/v1/cookbooks/users').to_return(
|
45
57
|
status: 200,
|
@@ -209,16 +221,28 @@ RSpec.describe PolicyChangelog do
|
|
209
221
|
|
210
222
|
it 'detects type for regular tag' do
|
211
223
|
allow(repo).to receive_message_chain(:tags, :last, :name).and_return('1.0.0')
|
224
|
+
allow(changelog).to receive(:sort_by_version).and_return(repo.tags)
|
212
225
|
expect(changelog.tag_format(repo)).to eq('')
|
213
226
|
end
|
214
227
|
|
215
228
|
it 'detects type for v-tag' do
|
216
229
|
allow(repo).to receive_message_chain(:tags, :last, :name).and_return('v1.0.0')
|
230
|
+
allow(changelog).to receive(:sort_by_version).and_return(repo.tags)
|
217
231
|
expect(changelog.tag_format(repo)).to eq('v')
|
218
232
|
end
|
219
233
|
end
|
220
234
|
end
|
221
235
|
|
236
|
+
describe '#sort_by_version' do
|
237
|
+
context 'when sorting' do
|
238
|
+
it 'sorts' do
|
239
|
+
expect(changelog.sort_by_version(tags).map(&:name)).to eq(
|
240
|
+
%w[invalid v0.1.1 0.9.1 1.0.0 v1.0.5 v1.1.1 5.2.1]
|
241
|
+
)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
222
246
|
describe '#reject_version_filter' do
|
223
247
|
context 'when current equal to target' do
|
224
248
|
it 'returns true' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-changelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregoire Seux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
requirements: []
|
245
245
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.7.
|
246
|
+
rubygems_version: 2.7.5
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
249
|
summary: Facilitate access to cookbooks changelog
|