swhid 0.2.0 → 0.2.1
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 +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/swhid/from_filesystem.rb +49 -0
- data/lib/swhid/version.rb +1 -1
- data/lib/swhid.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78a2795583924a21b4aae1a173e528af68805dd89ad44e6c3db32b534ca55653
|
|
4
|
+
data.tar.gz: 1a65c99bade2ae1c4f00c69d2b49a31708da9fc8f15ee5c63d7d9806c876b7e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9d04af133af2dca2b749ce7259a792dbed4622b7bfc587cc08be99d87e109d50be5926e0db2b653b3da7d0e74454fac3e4a9709b12fcd9306f4be20583eab97
|
|
7
|
+
data.tar.gz: 24affb1c2fa578ab1211b54540a3d2a51497e583b70804cf837c8999a2c8beb3c3546af6f0de35fe2743e26918fc775baf9f6ec0e75fad0d2d116b10730a412b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.1] - 2025-11-09
|
|
4
|
+
|
|
5
|
+
- Package manager tests for PyPI, RubyGems, Maven, Cargo, and NPM artifacts (content and extracted directories)
|
|
6
|
+
- Filesystem directory SWHID computation helper
|
|
7
|
+
|
|
3
8
|
## [0.2.0] - 2025-11-09
|
|
4
9
|
|
|
5
10
|
- Full implementation of all SWHID object types (content, directory, revision, release, snapshot)
|
|
@@ -7,7 +12,6 @@
|
|
|
7
12
|
- CLI tool with JSON output support
|
|
8
13
|
- Performance benchmarks
|
|
9
14
|
- Bug fixes for directory permissions and revision timestamp handling
|
|
10
|
-
- 100% test pass rate (67 tests, 108 assertions)
|
|
11
15
|
|
|
12
16
|
## [0.1.0] - 2025-11-09
|
|
13
17
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "digest/sha1"
|
|
4
|
+
require "find"
|
|
5
|
+
|
|
6
|
+
module Swhid
|
|
7
|
+
module FromFilesystem
|
|
8
|
+
def self.from_directory_path(path)
|
|
9
|
+
raise ArgumentError, "Path does not exist: #{path}" unless File.exist?(path)
|
|
10
|
+
raise ArgumentError, "Path is not a directory: #{path}" unless File.directory?(path)
|
|
11
|
+
|
|
12
|
+
entries = build_entries(path)
|
|
13
|
+
Swhid.from_directory(entries)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.build_entries(dir_path)
|
|
17
|
+
entries = []
|
|
18
|
+
|
|
19
|
+
Dir.foreach(dir_path) do |name|
|
|
20
|
+
next if name == "." || name == ".."
|
|
21
|
+
next if name == ".git"
|
|
22
|
+
|
|
23
|
+
full_path = File.join(dir_path, name)
|
|
24
|
+
stat = File.lstat(full_path)
|
|
25
|
+
|
|
26
|
+
entry = if File.symlink?(full_path)
|
|
27
|
+
target_content = File.readlink(full_path)
|
|
28
|
+
target_hash = Swhid.from_content(target_content).object_hash
|
|
29
|
+
{ name: name, type: :symlink, target: target_hash }
|
|
30
|
+
elsif stat.directory?
|
|
31
|
+
target_swhid = from_directory_path(full_path)
|
|
32
|
+
{ name: name, type: :dir, target: target_swhid.object_hash }
|
|
33
|
+
elsif stat.executable?
|
|
34
|
+
content = File.binread(full_path)
|
|
35
|
+
target_hash = Swhid.from_content(content).object_hash
|
|
36
|
+
{ name: name, type: :exec, target: target_hash }
|
|
37
|
+
else
|
|
38
|
+
content = File.binread(full_path)
|
|
39
|
+
target_hash = Swhid.from_content(content).object_hash
|
|
40
|
+
{ name: name, type: :file, target: target_hash }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
entries << entry
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
entries
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/swhid/version.rb
CHANGED
data/lib/swhid.rb
CHANGED
|
@@ -7,6 +7,7 @@ require_relative "swhid/objects/directory"
|
|
|
7
7
|
require_relative "swhid/objects/revision"
|
|
8
8
|
require_relative "swhid/objects/release"
|
|
9
9
|
require_relative "swhid/objects/snapshot"
|
|
10
|
+
require_relative "swhid/from_filesystem"
|
|
10
11
|
|
|
11
12
|
module Swhid
|
|
12
13
|
class Error < StandardError; end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swhid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Nesbitt
|
|
@@ -26,6 +26,7 @@ files:
|
|
|
26
26
|
- benchmark/benchmark.rb
|
|
27
27
|
- exe/swhid
|
|
28
28
|
- lib/swhid.rb
|
|
29
|
+
- lib/swhid/from_filesystem.rb
|
|
29
30
|
- lib/swhid/identifier.rb
|
|
30
31
|
- lib/swhid/objects/content.rb
|
|
31
32
|
- lib/swhid/objects/directory.rb
|