knife-changelog 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fc579c229163b128ddd103ce2781f9b9ade76c5652d5cee2b35be4aa0300a9f
4
- data.tar.gz: 542377730e977eb8d8cd4fb89cbb23e47db92380986e2679c03fa380b7792eb0
3
+ metadata.gz: 8be4794cbe4a60468b7bb2ff5ad22bd741ef974e3580b1cca57bb2d6aae48ed6
4
+ data.tar.gz: 7a1a688801825095a4ed8e5dc1ac5bf66fe6cf54276fc02be6539ed36df84a02
5
5
  SHA512:
6
- metadata.gz: 160785af9a8e1d0702fe055c10acbbb857a405ea6d4303cd592d57073d00f7ebb8bcc0fa08700dbae4277dcf415dbf4eed8b402e98c4f43edbf52e1e94846783
7
- data.tar.gz: c74421eccbddb0cf7bdb55585e237c9d7f4fb3cf01a1e98cac7f73b58d7ac194e6a8a497115bea7b61ae93b529d50f81d4dc46dba23f874aefc8ab5d88f8b7c9
6
+ metadata.gz: a99aeeed6a9505f636e0c1c8df1b8775d9f1e6dfd839240d3680e6c4526a15c568f8a14a1bd02133bd5f22f4bc6f95e093e581702c45ec50a71d41593715a939
7
+ data.tar.gz: bb700c5d7f199a831692f154f02fa7c64038f8b508e4069f309682b1546defbceeedc7a1dffcea4d20290d8966b869ae07037f9ad0c52e86558e027d28efc6cd
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'knife-changelog'
8
- spec.version = '1.3.0'
8
+ spec.version = '1.4.0'
9
9
  spec.authors = ['Gregoire Seux']
10
10
  spec.email = ['kamaradclimber@gmail.com']
11
11
  spec.summary = 'Facilitate access to cookbooks changelog'
@@ -42,6 +42,12 @@ class Chef
42
42
  long: '--submodules SUBMODULE[,SUBMODULE]',
43
43
  description: 'Submoduless to check for changes as well (comma separated)'
44
44
 
45
+ option :prevent_downgrade,
46
+ long: '--prevent-downgrade',
47
+ description: 'Fail if knife-changelog detect a cookbook downgrade',
48
+ boolean: true,
49
+ default: false
50
+
45
51
  option :policyfile,
46
52
  long: '--policyfile PATH',
47
53
  description: 'Link to policyfile, defaults to "Policyfile.rb"',
@@ -176,10 +176,20 @@ class PolicyChangelog
176
176
  data['current_version'] == data['target_version'] || data['target_version'].nil?
177
177
  end
178
178
 
179
+ # Search for cookbook downgrade and raise an error if any
180
+ def validate_downgrade!(data)
181
+ downgrade = data.select { |_, ck| ::Gem::Version.new(ck['target_version']) < ::Gem::Version.new(ck['current_version']) }
182
+
183
+ return if downgrade.empty?
184
+
185
+ details = downgrade.map { |name, data| "#{name} (#{data['current_version']} -> #{data['target_version']})" }
186
+ raise "Trying to downgrade following cookbooks: #{details.join(', ')}"
187
+ end
188
+
179
189
  # Generates Policyfile changelog
180
190
  #
181
191
  # @return [String] formatted version changelog
182
- def generate_changelog
192
+ def generate_changelog(prevent_downgrade: false)
183
193
  lock_current = read_policyfile_lock(@policyfile_dir)
184
194
  current = versions(lock_current['cookbook_locks'], 'current')
185
195
 
@@ -192,6 +202,9 @@ class PolicyChangelog
192
202
  else
193
203
  updated_cookbooks.select { |name, _data| @cookbooks_to_update.include?(name) }
194
204
  end
205
+
206
+ validate_downgrade!(updated_cookbooks) if prevent_downgrade
207
+
195
208
  generate_changelog_from_versions(changelog_cookbooks)
196
209
  end
197
210
 
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.3.0
4
+ version: 1.4.0
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-10-15 00:00:00.000000000 Z
11
+ date: 2020-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -243,8 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
245
  requirements: []
246
- rubyforge_project:
247
- rubygems_version: 2.7.7
246
+ rubygems_version: 3.0.3
248
247
  signing_key:
249
248
  specification_version: 4
250
249
  summary: Facilitate access to cookbooks changelog