feat(#141): export FileCoveredByDocMap helper in review/docmap.go

Adds FileCoveredByDocMap(cfg *DocMapConfig, file string) bool — a thin wrapper
over the existing unexported mappingMatches that lets cmd/ check per-file docmap
coverage without duplicating glob logic.

Also adds unit tests covering matched globs, non-matching paths, empty file,
and empty config.
This commit is contained in:
Rodin
2026-05-15 04:46:38 +00:00
parent 04b24256c0
commit 93268869c5
2 changed files with 61 additions and 0 deletions
+12
View File
@@ -66,6 +66,18 @@ func ParseDocMapConfig(localPath string) (*DocMapConfig, error) {
return &cfg, nil
}
// FileCoveredByDocMap reports whether at least one paths: glob in any mapping
// of cfg matches the given file path. It is used by static validation tooling
// (e.g. the validate-docmap subcommand) to check per-file docmap coverage.
func FileCoveredByDocMap(cfg *DocMapConfig, file string) bool {
for _, mapping := range cfg.Mappings {
if mappingMatches(mapping.Paths, []string{file}) {
return true
}
}
return false
}
// MatchDocs returns deduplicated doc paths for the given changed file paths.
// A mapping matches if any of its path globs matches any of the changed files.
func MatchDocs(cfg *DocMapConfig, changedFiles []string) []string {