wip: findr.

This commit is contained in:
2026-06-17 08:54:03 -04:00
parent 55ed98659b
commit dd522de02c
7 changed files with 780 additions and 219 deletions

View File

@@ -161,17 +161,23 @@ parse :: proc(content: string) -> Gitignore {
return gi
}
is_ignored :: proc(gi: ^Gitignore, path: string, is_dir: bool) -> bool {
matched := false
Match :: enum { None, Ignored, Unignored }
check_match :: proc(gi: ^Gitignore, path: string, is_dir: bool) -> Match {
result := Match.None
for rule in gi.rules {
if rule.dir_only && !is_dir do continue
cap, ok := regex.match(rule.regex, path)
regex.destroy(cap)
if ok {
matched = !rule.negated
result = rule.negated ? .Unignored : .Ignored
}
}
return matched
return result
}
is_ignored :: proc(gi: ^Gitignore, path: string, is_dir: bool) -> bool {
return check_match(gi, path, is_dir) == .Ignored
}
destroy :: proc(gi: ^Gitignore) {