swhid 0.4.0 → 0.4.2

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
  SHA256:
3
- metadata.gz: ee71514f26b0e91e02344d741fdfb56dc4aa5d9314e30dcc3c5d85caa68f8973
4
- data.tar.gz: 4f087cd83b505e88543e991aa24d8fb88368596e4b108128de52d562e2d81025
3
+ metadata.gz: 16ba287ac96b6a5e50f4dd578cbb4af414d360dd1b4de71d0d8c335eca848891
4
+ data.tar.gz: a4d5c2f729d7cb608abbfdec6dea9813c8baf4c64fbc78c703bef2cb40836f86
5
5
  SHA512:
6
- metadata.gz: a94007e0ee145b967ec7f2ac0007dcf996207990bec1af8ce3a63fc4f0ddd0e4a59afe6bf1385a4e0f9b9b033a3f0301657835751e653b1f1ed5fb457a3a6b90
7
- data.tar.gz: 0f8a27c61f50d91519564fe4f7a6483b23415c600ffc6d49df26141388faf71ab547aa06e56450a6df9d95b91d6560c3c773a65c80682e6d87d5538858fd5e68
6
+ metadata.gz: 04e2af979856db63384d9080b60182e0e62ffbf6ddeb93dc6037c52a22979eaed8b00d116aa3c7ca47081c2984314b157dd308493d7d1f66159b3c62088f1d18
7
+ data.tar.gz: e10d4fa950666e101c872cb033b4e094bcc149131eebddac8431623569805ea7b909633417b4b30da628d3f3774ef2a34dcac05bcb5fb86f34159845d45a871a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.2] - 2026-01-14
4
+
5
+ ### Fixed
6
+ - CLI now reads stdin and writes stdout in binary mode (fixes CRLF and binary file handling on Windows)
7
+ - Normalize path separators for Git index lookups on Windows
8
+
9
+ ### Added
10
+ - CLI integration tests for binary content and line ending preservation
11
+
12
+ ## [0.4.1] - 2026-01-13
13
+
14
+ ### Fixed
15
+ - Resolve symlinks when matching paths for Git index permission lookups
16
+
3
17
  ## [0.4.0] - 2026-01-12
4
18
 
5
19
  ### Added
data/exe/swhid CHANGED
@@ -6,6 +6,9 @@ require "swhid"
6
6
  require "optparse"
7
7
  require "json"
8
8
 
9
+ # Ensure consistent LF line endings on all platforms
10
+ $stdout.binmode
11
+
9
12
  class SwhidCLI
10
13
  def initialize(args)
11
14
  @args = args
@@ -96,6 +99,7 @@ class SwhidCLI
96
99
  end
97
100
 
98
101
  def compute_content_swhid
102
+ $stdin.binmode
99
103
  content = $stdin.read
100
104
 
101
105
  swhid = Swhid.from_content(content)
@@ -57,7 +57,8 @@ module Swhid
57
57
  def self.file_executable?(full_path, stat, git_repo, permissions = nil)
58
58
  # Check explicit permissions map first (from tar extraction, etc.)
59
59
  if permissions
60
- mode = permissions[full_path] || permissions[File.expand_path(full_path)]
60
+ real_path = File.realpath(full_path) rescue File.expand_path(full_path)
61
+ mode = permissions[full_path] || permissions[real_path]
61
62
  return (mode & 0o111) != 0 if mode
62
63
  end
63
64
 
@@ -81,14 +82,20 @@ module Swhid
81
82
  repo_workdir = git_repo.workdir
82
83
  return nil unless repo_workdir
83
84
 
84
- full_path = File.expand_path(full_path)
85
- repo_workdir = File.expand_path(repo_workdir)
85
+ # Use realpath to resolve symlinks (e.g., /tmp -> /private/tmp on macOS)
86
+ full_path = File.realpath(full_path) rescue File.expand_path(full_path)
87
+ repo_workdir = File.realpath(repo_workdir) rescue File.expand_path(repo_workdir)
88
+
89
+ # Normalize path separators for consistent comparison (especially on Windows)
90
+ full_path = full_path.tr("\\", "/")
91
+ repo_workdir = repo_workdir.tr("\\", "/")
92
+
93
+ # Ensure repo_workdir ends with separator for proper prefix matching
94
+ repo_workdir = repo_workdir.chomp("/") + "/"
86
95
 
87
96
  return nil unless full_path.start_with?(repo_workdir)
88
97
 
89
- relative = full_path.sub(repo_workdir, "")
90
- relative = relative[1..] if relative.start_with?("/") || relative.start_with?("\\")
91
- relative.tr("\\", "/")
98
+ full_path.sub(repo_workdir, "")
92
99
  end
93
100
  end
94
101
  end
data/lib/swhid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Swhid
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.2"
5
5
  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.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt