Skip to content

fix(scripts): loadMintIgnore mis-parses dir patterns without leading … - #1982

Open
forumevi wants to merge 1 commit into
base:masterfrom
forumevi:patch-1
Open

forumevi wants to merge 1 commit into
base:masterfrom
forumevi:patch-1

Conversation

@forumevi

Copy link
Copy Markdown

What's broken

loadMintIgnore in scripts/lib/docs-utils.js mis-parses .mintignore
directory patterns (lines ending in /*) that don't start with a leading
slash.

if (trimmed.endsWith('/*')) {
  ignored.dirs.add(trimmed.slice(1, -2));
}

slice(1, -2) unconditionally drops the first character, assuming it's
always the leading /. For a pattern without one, it instead drops the
first character of the real directory name:

"/docs/*".slice(1, -2)  -> "docs"   (correct)
"docs/*".slice(1, -2)   -> "ocs"    (wrong — should be "docs")

Any .mintignore directory entry written without a leading slash (e.g.
docs/* instead of /docs/*) silently ends up ignoring the wrong directory
name, so the intended directory is never actually skipped by the docs-tree
generators that consume this list.

Fix

Strip the trailing /* first, then only strip a leading / if one is
actually present:

if (trimmed.endsWith('/*')) {
  const dirPattern = trimmed.slice(0, -2);
  ignored.dirs.add(dirPattern.startsWith('/') ? dirPattern.slice(1) : dirPattern);
}

This keeps existing anchored patterns (/docs/*) working exactly as before,
and fixes unanchored ones (docs/*, nested/dir/*) to resolve to the
correct directory name instead of a truncated one.

Fixes #

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants