simp-rake-helpers 3.6.0 → 3.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f87a58cc38f4d236c1c66e94f9145377b430546
4
- data.tar.gz: 1f2c7a736e3974a0ce72a65d778b8cd28c75f318
3
+ metadata.gz: 6c1179db907c046e2587aba51d6d8bafb4387ccd
4
+ data.tar.gz: a8b41cc9cb002d18a0bec544ea7389328198588d
5
5
  SHA512:
6
- metadata.gz: 2649f7dc066a02e254e531bd3901b568f0e846892418276a30a5ccd190c3cadbcdb468372038aaf4df245512f6b4b2f4d5931729cb1505b0083db63eed49fea2
7
- data.tar.gz: eea647a6d2f28d9ace0458b12119888a179cacb248807842486339cd04bd83bd9ddef879a5ffd3bfefec9187d371fd6b8d3ea2694902b0fd941e8465cd05ba90
6
+ metadata.gz: 85ebb2471f4f3648d3ab3235ad2c268daa8bc09466b76c28c649b7bcb6915be019f495d7e1dd42a25a5d7e48a8613e1da6821db0d18621a0f8efcf5b68db6b03
7
+ data.tar.gz: b35605270a2148c09f2ca1803c55703bacf4ff56223a343ecce39b3f1732e79463e30f20614db161e4fba522240e33795ff471bb118efa3b530ac1475a8d84fa
@@ -1,3 +1,6 @@
1
+ ### 3.7.0 / 2017-07-10
2
+ * Added compare_latest_tag task
3
+
1
4
  ### 3.6.0 / 2017-07-03
2
5
  * Added changelog_annotation task
3
6
 
@@ -2,5 +2,5 @@ module Simp; end
2
2
  module Simp::Rake; end
3
3
 
4
4
  class Simp::Rake::Helpers
5
- VERSION = '3.6.0'
5
+ VERSION = '3.7.0'
6
6
  end
@@ -146,6 +146,101 @@ class Simp::Rake::Pupmod::Helpers < ::Rake::TaskLib
146
146
  puts changelog[module_version]
147
147
  end
148
148
 
149
+ desc <<-EOM
150
+ Compare to latest tag.
151
+ ARGS:
152
+ * :tags_source => Set to the remote from which the tags for this
153
+ project can be fetched, e.g. 'upstream' for a
154
+ forked project. Defaults to 'origin'.
155
+ * :ignore_owner => Execute comparison even if the project owner
156
+ is not 'simp'.
157
+ * :verbose => Set to 'true' if you want to see detailed messages
158
+
159
+ NOTES:
160
+ Compares mission-impacting (significant) files with the latest
161
+ tag and identifies the relevant files that have changed.
162
+
163
+ Does nothing if the project owner, as specified in the
164
+ metadata.json file, is not 'simp'.
165
+
166
+ When mission-impacting files have changed, fails if
167
+ (1) Latest version cannot be extracted from the top-most
168
+ CHANGELOG entry.
169
+ (2) The latest version in the CHANGELOG (minus the release
170
+ qualifier) does not match the version in the metadata.json
171
+ file.
172
+ (3) A version bump is required but not recorded in both the
173
+ CHANGELOG and metadata.json files.
174
+ (4) The latest version is < latest tag.
175
+
176
+ Changes to the following files/directories are not considered
177
+ significant:
178
+ - Any hidden file/directory (entry that begins with a '.')
179
+ - Gemfile
180
+ - Gemfile.lock
181
+ - Rakefile
182
+ - spec directory
183
+ - doc directory
184
+ EOM
185
+ task :compare_latest_tag, [:tags_source, :ignore_owner, :verbose] do |t,args|
186
+ require 'json'
187
+ require 'puppet/util/package'
188
+
189
+ tags_source = args[:tags_source].nil? ? 'origin' : args[:tags_source]
190
+ ignore_owner = true if args[:ignore_owner].to_s == 'true'
191
+ verbose = true if args[:verbose].to_s == 'true'
192
+
193
+ metadata = JSON.load(File.read('metadata.json'))
194
+ module_version = metadata['version']
195
+ owner = metadata['name'].split('-')[0]
196
+
197
+ if (owner == 'simp') or ignore_owner
198
+ # determine last tag
199
+ `git fetch -t #{tags_source} 2>/dev/null`
200
+ tags = `git tag -l`.split("\n")
201
+ puts "Available tags from #{tags_source} = #{tags}" if verbose
202
+ tags.delete_if { |tag| tag.include?('-') or (tag =~ /^v/) }
203
+
204
+ if tags.empty?
205
+ puts "No tags exist from #{tags_source}"
206
+ else
207
+ last_tag = (tags.sort { |a,b| Puppet::Util::Package::versioncmp(a,b) })[-1]
208
+
209
+ # determine mission-impacting files that have changed
210
+ files_changed = `git diff tags/#{last_tag} --name-only`.strip.split("\n")
211
+ files_changed.delete_if do |file|
212
+ file[0] == '.' or file =~ /^Gemfile/ or file == 'Rakefile' or file =~/^spec\// or file =~/^doc/
213
+ end
214
+
215
+ if files_changed.empty?
216
+ puts " No new tag required: No significant files have changed since '#{last_tag}' tag"
217
+ else
218
+ # determine latest CHANGELOG version
219
+ line = IO.readlines('CHANGELOG')[0]
220
+ match = line.match(/^\*\s+((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2} \d{4})\s+(.+<.+>)(?:\s+|\s*-\s*)?(\d+\.\d+\.\d+)/)
221
+ unless match
222
+ fail("ERROR: Invalid CHANGELOG entry. Unable to extract version from '#{line}'")
223
+ end
224
+
225
+ changelog_version = match[3]
226
+ unless module_version == changelog_version
227
+ fail("ERROR: Version mismatch. module version=#{module_version} changelog version=#{changelog_version}")
228
+ end
229
+
230
+ cmp_result = Puppet::Util::Package::versioncmp(module_version, last_tag)
231
+ if cmp_result < 0
232
+ fail("ERROR: Version regression. '#{module_version}' < last tag '#{last_tag}'")
233
+ elsif cmp_result == 0
234
+ fail("ERROR: Version update beyond last tag '#{last_tag}' is required for changes to #{files_changed}")
235
+ else
236
+ puts " New tag of version '#{module_version}' is required for changes to #{files_changed}"
237
+ end
238
+ end
239
+ end
240
+ else
241
+ puts " Not evaluating module owned by '#{owner}'"
242
+ end
243
+ end
149
244
 
150
245
  desc "Run syntax, lint, and spec tests."
151
246
  task :test => [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simp-rake-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Tessmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-07 00:00:00.000000000 Z
12
+ date: 2017-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler