Builtin Library
README.md
world_vcs.ignore
The .zmignore / .gitignore rules of a world, in gitignore(5) syntax: * / ? / [abc] / ** globs, ! negation, a leading / anchoring a pattern to its file's directory, a trailing / for directories only, # comments. A deeper ignore file overrides its parents, and the last matching rule wins.
setFrom(ignorePaths, read)reads each ignore file atignorePathsthroughreadand answers the ignore set,{ patterns }./source/agents/.zmignore, which the engine writes for its own records, states its own name as a rule beside the rules it holds.isIgnored(set, path)answers whetherpath(/source/...or/zero/source/...) matches the set.ruleFor(set, path)answers the{ file, rule }that ignorespath, or nil.isIgnoreFilePath(path)answers whetherpathis a.zmignore/.gitignorefile. Such a file is matched only by a rule whose last segment is its own name, written out (.zmignore,agents/.zmignore); wildcards and rules naming a folder above it never match it.
local Ignore = require("modules.world_vcs.ignore")
local set = Ignore.setFrom({ "/zero/source/.zmignore" }, vfs.read)
print(Ignore.isIgnored(set, "/source/scene_dirty/entities/a.json"))