revision 1.6.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.envrc +2 -0
- data/.gitignore +4 -1
- data/README.org +2 -2
- data/flake.lock +27 -0
- data/flake.nix +20 -0
- data/lib/revision/{md5.rb → checksum.rb} +14 -10
- data/lib/revision/cli.rb +20 -5
- data/lib/revision/releasable.rb +14 -12
- data/lib/revision/version.rb +8 -2
- data/releasables.yaml +3 -3
- data/revision.gemspec +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbca11f977b41b9b983ee0aa3fb2dc1a9617098a275c991b78d19d90eca48ee6
|
4
|
+
data.tar.gz: 46f8c0153fac4a040aaf67e1e73670e5deb3d338be770734c787a8941c5c89a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 358518474ea83403e94ec3a0691bee2dfcd2e2b7fb080492a1fca0c28ddde6992390aa0096fd88a210659c25305b60a304623f255670d4279abfd722c461e758
|
7
|
+
data.tar.gz: 287f6c4f9ae8d0e21e6fa82a2323268c1aafc1a2eef9710254b0df1331aa8080a68623bc7ecf937a49c4629e972ae2a7be806b556dec88b5827f9bee2043e51c
|
data/.envrc
ADDED
data/.gitignore
CHANGED
data/README.org
CHANGED
@@ -198,9 +198,9 @@ The lines beginning with '#' are explanatory comments
|
|
198
198
|
- :src: pkg/revision-<VER>.gem
|
199
199
|
:dest: revision-<VER>.gem
|
200
200
|
# ':dest:' defaults to the string specified for ':src:' if not specified explicitly
|
201
|
-
#
|
201
|
+
# sha512 checksums are generated by default for each artefact -- the ':chk:' option allows this to be disabled per-artefact
|
202
202
|
- :src: README.org
|
203
|
-
:
|
203
|
+
:chk: false
|
204
204
|
#+END_SRC
|
205
205
|
|
206
206
|
**** TODO (or at least consider) add support for overridable defaults
|
data/flake.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"nodes": {
|
3
|
+
"nixpkgs": {
|
4
|
+
"locked": {
|
5
|
+
"lastModified": 1699343069,
|
6
|
+
"narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=",
|
7
|
+
"owner": "NixOS",
|
8
|
+
"repo": "nixpkgs",
|
9
|
+
"rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d",
|
10
|
+
"type": "github"
|
11
|
+
},
|
12
|
+
"original": {
|
13
|
+
"owner": "NixOS",
|
14
|
+
"ref": "nixpkgs-unstable",
|
15
|
+
"repo": "nixpkgs",
|
16
|
+
"type": "github"
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"root": {
|
20
|
+
"inputs": {
|
21
|
+
"nixpkgs": "nixpkgs"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"root": "root",
|
26
|
+
"version": 7
|
27
|
+
}
|
data/flake.nix
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
description = "A Nix-flake-based Ruby development environment";
|
3
|
+
|
4
|
+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
5
|
+
|
6
|
+
outputs = { self, nixpkgs }:
|
7
|
+
let
|
8
|
+
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
9
|
+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
10
|
+
pkgs = import nixpkgs { inherit system; };
|
11
|
+
});
|
12
|
+
in
|
13
|
+
{
|
14
|
+
devShells = forEachSupportedSystem ({ pkgs }: {
|
15
|
+
default = pkgs.mkShell {
|
16
|
+
packages = with pkgs; [ ruby_3_2 ];
|
17
|
+
};
|
18
|
+
});
|
19
|
+
};
|
20
|
+
}
|
@@ -1,34 +1,38 @@
|
|
1
1
|
require 'digest'
|
2
2
|
|
3
|
-
class Revision::
|
3
|
+
class Revision::Checksum
|
4
4
|
|
5
5
|
READ_CHUNK_KB = 1024
|
6
6
|
FILENAME_EXTENSION = "md5"
|
7
7
|
|
8
|
+
MD5 = {name: "md5", generator: Digest::MD5}
|
9
|
+
SHA512 = {name: "sha512", generator: Digest::SHA512}
|
10
|
+
|
8
11
|
attr_reader :root, :filename
|
9
12
|
|
10
|
-
def self.from_file(filepath, filename: nil)
|
13
|
+
def self.from_file(filepath, filename: nil, type: SHA512)
|
11
14
|
raise "File #{filepath} not found" unless File.exist?(filepath)
|
12
15
|
filename ||= File.basename(filepath)
|
13
16
|
root = File.dirname(filepath)
|
14
17
|
stream = File.open(filepath, 'rb')
|
15
|
-
new(stream, filename, root: root)
|
18
|
+
new(stream, filename, root: root, type: type)
|
16
19
|
end
|
17
20
|
|
18
|
-
def initialize(ioreader, filename, root: nil)
|
21
|
+
def initialize(ioreader, filename, root: nil, type: SHA512)
|
19
22
|
root ||= Dir.getwd
|
20
23
|
@reader = ioreader
|
21
24
|
@root = root
|
22
25
|
@filename = filename
|
26
|
+
@impl = type
|
23
27
|
end
|
24
28
|
|
25
29
|
def calc
|
26
|
-
|
30
|
+
checksum = @impl[:generator].new
|
27
31
|
bytes_per_chunk = READ_CHUNK_KB*1024
|
28
32
|
while chunk = @reader.read(bytes_per_chunk)
|
29
|
-
|
33
|
+
checksum << chunk
|
30
34
|
end
|
31
|
-
|
35
|
+
checksum.hexdigest
|
32
36
|
end
|
33
37
|
|
34
38
|
def to_s
|
@@ -37,12 +41,12 @@ class Revision::MD5
|
|
37
41
|
EOT
|
38
42
|
end
|
39
43
|
|
40
|
-
def
|
41
|
-
"#{@filename}.#{
|
44
|
+
def chkfilename
|
45
|
+
"#{@filename}.#{@impl[:name]}"
|
42
46
|
end
|
43
47
|
|
44
48
|
def write(filepath: nil)
|
45
|
-
filepath ||= File.join(@root,
|
49
|
+
filepath ||= File.join(@root, chkfilename)
|
46
50
|
filename = File.basename(filepath)
|
47
51
|
File.open(filepath, "w") { |f| f.write "#{calc} #{filename}" }
|
48
52
|
filepath
|
data/lib/revision/cli.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative 'releasable'
|
|
4
4
|
require_relative 'info'
|
5
5
|
require_relative 'errors'
|
6
6
|
require_relative 'version'
|
7
|
-
require_relative '
|
7
|
+
require_relative 'checksum'
|
8
8
|
|
9
9
|
module Revision
|
10
10
|
class CLI < Thor
|
@@ -111,13 +111,28 @@ module Revision
|
|
111
111
|
def md5
|
112
112
|
r = select_one
|
113
113
|
files = options[:file].nil? ?
|
114
|
-
r.artefacts.select { |a| a[:
|
114
|
+
r.artefacts.select { |a| a[:chk]==true }.map { |a| a[:src] } :
|
115
115
|
[options[:file]]
|
116
116
|
raise "No files specified" unless files.length
|
117
|
-
puts "Calculating
|
117
|
+
puts "Calculating checksum for files #{files}"
|
118
118
|
for f in files
|
119
|
-
|
120
|
-
puts "#{
|
119
|
+
checksum = Revision::Checksum.from_file(f, type: Revision::Checksum::MD5)
|
120
|
+
puts "#{checksum}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
desc 'chk', 'Compute sha512 checksums for current build artefacts'
|
125
|
+
method_option :file, :aliases => "-f", :type => :string, :default => nil ,:desc => "File to checksum (defaults to build artefacts defined in yaml)"
|
126
|
+
def chk
|
127
|
+
r = select_one
|
128
|
+
files = options[:file].nil? ?
|
129
|
+
r.artefacts.select { |a| a[:chk]==true }.map { |a| a[:src] } :
|
130
|
+
[options[:file]]
|
131
|
+
raise "No files specified" unless files.length
|
132
|
+
puts "Calculating checksum for files #{files}"
|
133
|
+
for f in files
|
134
|
+
checksum = Revision::Checksum.from_file(f, type: Revision::Checksum::SHA512)
|
135
|
+
puts "#{checksum}"
|
121
136
|
end
|
122
137
|
end
|
123
138
|
|
data/lib/revision/releasable.rb
CHANGED
@@ -69,7 +69,7 @@ module Revision
|
|
69
69
|
@build_def = config[:build] ? config[:build] : { environment: { variables: {}}, steps: config[:build_steps]}
|
70
70
|
@artefacts = config[:artefacts] || []
|
71
71
|
@artefacts.each { |a| a[:dest] ||= File.basename(a[:src]) } unless @artefacts.nil? || @artefacts.empty?
|
72
|
-
# @artefacts.each { |a| a[:
|
72
|
+
# @artefacts.each { |a| a[:chk] = true if a[:chk].nil? } unless @artefacts.nil? || @artefacts.empty?
|
73
73
|
@config = config
|
74
74
|
end
|
75
75
|
|
@@ -194,10 +194,12 @@ module Revision
|
|
194
194
|
|
195
195
|
def normalise_artefact(a)
|
196
196
|
src_norm = interp_rev(a[:src])
|
197
|
+
# the :chk key replaced a legacy :md5 key -- support old syntax
|
198
|
+
chk_unified = a[:chk].nil? ? a[:md5] : a[:chk]
|
197
199
|
a_norm = {
|
198
200
|
src: src_norm,
|
199
201
|
dest: a[:dest].nil? ? File.basename(src_norm) : interp_rev(a[:dest]),
|
200
|
-
|
202
|
+
chk: chk_unified.nil? ? true : chk_unified
|
201
203
|
}
|
202
204
|
if Gem.win_platform? && !a_norm[:src].end_with?('.exe') && File.exist?(File.join(@root, a_norm[:src] + '.exe'))
|
203
205
|
puts "... windows platform -- appending '.exe' ('#{a_norm[:src]}' -> '#{a_norm[:src]}.exe')"
|
@@ -222,27 +224,27 @@ module Revision
|
|
222
224
|
zip_entries.each.with_index(1) do |a, idx|
|
223
225
|
puts "... (#{idx}/#{zip_entries.length}) #{a[:dest]} :: <= #{a[:src]}"
|
224
226
|
zipfile.add(a[:dest], a[:src])
|
225
|
-
if a[:
|
226
|
-
|
227
|
-
puts "... (#{idx}/#{zip_entries.length}) #{a[:dest]} :: embedding
|
228
|
-
zipfile.get_output_stream(
|
227
|
+
if a[:chk]
|
228
|
+
chkfile = Checksum.from_file(a[:src])
|
229
|
+
puts "... (#{idx}/#{zip_entries.length}) #{a[:dest]} :: embedding checksum (#{chkfile.chkfilename})"
|
230
|
+
zipfile.get_output_stream(chkfile.chkfilename) { |os| os.write("#{chkfile}")}
|
229
231
|
else
|
230
|
-
puts "... (#{idx}/#{zip_entries.length}) #{a[:dest]} :: no
|
232
|
+
puts "... (#{idx}/#{zip_entries.length}) #{a[:dest]} :: no checksum required"
|
231
233
|
end
|
232
234
|
end
|
233
235
|
puts "... embedding revision history as #{changelog_name} "
|
234
236
|
zipfile.get_output_stream(changelog_name) { |os| output_changelog(os)}
|
235
237
|
end
|
236
|
-
|
237
|
-
puts "... generating archive
|
238
|
-
|
238
|
+
archive_checksum = Checksum.from_file(archive_name)
|
239
|
+
puts "... generating archive checksum as #{archive_checksum.chkfilename} "
|
240
|
+
archive_checksum.write
|
239
241
|
|
240
242
|
if @config.dig(:archive)
|
241
243
|
archive_root = File.expand_path(@config[:archive])
|
242
244
|
puts "... moving #{archive_name} to #{archive_root}"
|
243
245
|
FileUtils.mkdir_p(archive_root)
|
244
246
|
FileUtils.mv(archive_name, archive_root)
|
245
|
-
FileUtils.mv(
|
247
|
+
FileUtils.mv(archive_checksum.chkfilename, archive_root)
|
246
248
|
end
|
247
249
|
end
|
248
250
|
|
@@ -283,7 +285,7 @@ module Revision
|
|
283
285
|
end
|
284
286
|
puts "... deploying '#{src}' -> '#{dest}'"
|
285
287
|
FileUtils.cp_r(src,dest)
|
286
|
-
puts "... writing
|
288
|
+
puts "... writing checksum for '#{dest}' to '#{Checksum.from_file(dest).write}'" if a[:chk]
|
287
289
|
end
|
288
290
|
File.open(File.join(destination,changelog_name),'w') { |f| output_changelog(f)}
|
289
291
|
|
data/lib/revision/version.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
# Defines the revision ID for the revision gem
|
2
2
|
module Revision
|
3
|
-
VERSION = "
|
3
|
+
VERSION = "2.0.1".freeze
|
4
4
|
end
|
5
5
|
|
6
6
|
# <BEGIN CHANGELOG>
|
7
7
|
#
|
8
|
+
# Version 2.0.1 (30 Nov 2023)
|
9
|
+
# - deps(thor): Relaxed version dep from ~>1.0 to >=0.14
|
10
|
+
#
|
11
|
+
# Version 2.0.0 (10 Nov 2023)
|
12
|
+
# - new(checksum): Now using SHA512 rather than MD5 checksums
|
13
|
+
#
|
8
14
|
# Version 1.6.1 (31 Aug 2022)
|
9
15
|
# - Fixed logging error preventing windows exe creation
|
10
16
|
#
|
11
17
|
# Version 1.6.0 (01 Dec 2021)
|
12
|
-
# - New feature: Automated
|
18
|
+
# - New feature: Automated checksum generation during 'archive' and 'deploy' tasks
|
13
19
|
#
|
14
20
|
# Version 1.5.3 (26 Oct 2021)
|
15
21
|
# - Multiple deployment destinations bugfix -- only last destination was being used.
|
data/releasables.yaml
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
- mkdir -p test-output/2
|
9
9
|
- bundle exec rake install
|
10
10
|
#Define 3 build artefacts as test cases for 'deploy' and 'archive' tasks
|
11
|
-
#Expect
|
11
|
+
#Expect checksum file to be generated by default for first entry (where not specified explicitly)
|
12
12
|
:artefacts:
|
13
13
|
- :src: pkg/revision-<VER>.gem
|
14
14
|
- :src: README.org
|
15
|
-
:
|
15
|
+
:chk: false
|
16
16
|
- :src: Rakefile
|
17
|
-
:
|
17
|
+
:chk: true
|
18
18
|
#Define two deployment destinations to verify multiple deployments work as intended
|
19
19
|
:deploy:
|
20
20
|
- :dest: ./test-output
|
data/revision.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'thor', '
|
24
|
+
spec.add_runtime_dependency 'thor', '>= 0.14'
|
25
25
|
spec.add_runtime_dependency 'rubyzip', '~> 2.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 2.0"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cormac Cannon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0.14'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubyzip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,6 +187,7 @@ executables:
|
|
187
187
|
extensions: []
|
188
188
|
extra_rdoc_files: []
|
189
189
|
files:
|
190
|
+
- ".envrc"
|
190
191
|
- ".gitignore"
|
191
192
|
- ".rspec"
|
192
193
|
- ".travis.yml"
|
@@ -197,11 +198,13 @@ files:
|
|
197
198
|
- bin/console
|
198
199
|
- bin/setup
|
199
200
|
- exe/revision
|
201
|
+
- flake.lock
|
202
|
+
- flake.nix
|
200
203
|
- lib/revision.rb
|
204
|
+
- lib/revision/checksum.rb
|
201
205
|
- lib/revision/cli.rb
|
202
206
|
- lib/revision/errors.rb
|
203
207
|
- lib/revision/info.rb
|
204
|
-
- lib/revision/md5.rb
|
205
208
|
- lib/revision/releasable.rb
|
206
209
|
- lib/revision/string_case.rb
|
207
210
|
- lib/revision/version.rb
|
@@ -227,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
230
|
- !ruby/object:Gem::Version
|
228
231
|
version: '0'
|
229
232
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
233
|
+
rubygems_version: 3.4.20
|
231
234
|
signing_key:
|
232
235
|
specification_version: 4
|
233
236
|
summary: Language-agnostic revision management tool
|