Skip to content

Commit 2ca7cc4

Browse files
committed
Package.Fetch: fix inclusions not working for directories
Oops, the loop was checking the wrong variable! Added a unit test.
1 parent aaf4618 commit 2ca7cc4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Package/Fetch.zig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,12 +1510,22 @@ const Filter = struct {
15101510
// Check if any included paths are parent directories of sub_path.
15111511
var dirname = sub_path;
15121512
while (std.fs.path.dirname(dirname)) |next_dirname| {
1513-
if (self.include_paths.contains(sub_path)) return true;
1513+
if (self.include_paths.contains(next_dirname)) return true;
15141514
dirname = next_dirname;
15151515
}
15161516

15171517
return false;
15181518
}
1519+
1520+
test includePath {
1521+
const gpa = std.testing.allocator;
1522+
var filter: Filter = .{};
1523+
defer filter.include_paths.deinit(gpa);
1524+
1525+
try filter.include_paths.put(gpa, "src", {});
1526+
try std.testing.expect(filter.includePath("src/core/unix/SDL_poll.c"));
1527+
try std.testing.expect(!filter.includePath(".gitignore"));
1528+
}
15191529
};
15201530

15211531
pub fn depDigest(
@@ -1556,3 +1566,7 @@ const git = @import("Fetch/git.zig");
15561566
const Package = @import("../Package.zig");
15571567
const Manifest = Package.Manifest;
15581568
const ErrorBundle = std.zig.ErrorBundle;
1569+
1570+
test {
1571+
_ = Filter;
1572+
}

0 commit comments

Comments
 (0)