Skip to content

Commit e380465

Browse files
committed
Fix pony-lint ignore matching on Windows
The ignore matcher hardcoded `/` as the path separator in three places, causing all ignore rules to silently fail on Windows where paths use `\`. Closes #5053
1 parent e4c5cb8 commit e380465

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Fix pony-lint ignore matching on Windows
2+
3+
pony-lint's `.gitignore` and `.ignore` pattern matching failed on Windows because path separator handling was hardcoded to `/`. On Windows, where paths use `\`, ignore rules were silently ineffective — files that should have been skipped were linted, and anchored patterns like `src/build/` never matched.

tools/pony-lint/ignore_matcher.pony

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@ class ref IgnoreMatcher
126126

127127
let matched =
128128
if pat.anchored then
129-
// Match against path relative to the rule's base directory
129+
// Match against path relative to the rule's base directory,
130+
// normalized to forward slashes for GlobMatch
130131
let rel =
131132
try
132-
Path.rel(base_dir, abs_path)?
133+
let r = Path.rel(base_dir, abs_path)?
134+
ifdef windows then
135+
let s = r.clone()
136+
s.replace("\\", "/")
137+
consume s
138+
else
139+
r
140+
end
133141
else
134142
abs_path
135143
end
@@ -154,9 +162,9 @@ class ref IgnoreMatcher
154162
"""
155163
if abs_path.at(base_dir) then
156164
let blen = base_dir.size()
157-
// Exact match or path continues with /
165+
// Exact match or path continues with a separator
158166
(abs_path.size() == blen)
159-
or (try abs_path(blen)? == '/' else false end)
167+
or (try Path.is_sep(abs_path(blen)?) else false end)
160168
else
161169
false
162170
end

tools/pony-lint/linter.pony

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class val Linter
457457
else
458458
return
459459
end
460-
let parts = rel.split_by("/")
460+
let parts = rel.split_by(Path.sep())
461461
var current: String val = root
462462
for part in (consume parts).values() do
463463
current = Path.join(current, part)

0 commit comments

Comments
 (0)