From 9f715839f9348a8f70856bdacd00d34a0cc1e629 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 14 Jul 2026 11:02:49 +0200 Subject: [PATCH] docs-deploy: Collapse three glob matchers into one The context script defined matchesGlob inline in the vale-paths block, a bespoke isIgnored with identical semantics, and a matchesPattern whose only real case was the /** suffix. Hoist one matchesGlob and express the other two through it, preserving matchesPattern's fail-open behavior for non-/** shapes. Co-Authored-By: Claude Fable 5 --- .github/workflows/docs-deploy.yml | 39 +++++++++++-------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index 398a228..d6fc451 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -113,27 +113,22 @@ jobs: const ignoreLines = (process.env.IGNORE_PATTERNS || '') .split('\n').map(s => s.trim()).filter(Boolean); - const matchesPattern = (filename) => { - if (pathPattern === '**' || pathPattern === '') return true; - if (pathPattern.endsWith('/**')) { - return filename.startsWith(pathPattern.slice(0, -3) + '/'); + // No checkout in this workflow_run phase, so patterns are matched + // against API filenames: dir/** (subtree), dir/* (direct children), exact. + const matchesGlob = (f, pattern) => { + if (pattern.endsWith('/**')) return f.startsWith(pattern.slice(0, -3) + '/'); + if (pattern.endsWith('/*')) { + const dir = pattern.slice(0, -2); + return f.startsWith(dir + '/') && !f.slice(dir.length + 1).includes('/'); } - return true; + return f === pattern; }; - const isIgnored = (filename) => { - for (const pattern of ignoreLines) { - if (pattern.endsWith('/**')) { - if (filename.startsWith(pattern.slice(0, -3) + '/')) return true; - } else if (pattern.endsWith('/*')) { - const dir = pattern.slice(0, -2); - if (filename.startsWith(dir + '/') && !filename.slice(dir.length + 1).includes('/')) return true; - } else if (filename === pattern) { - return true; - } - } - return false; - }; + // Fails open: any pattern shape other than dir/** matches everything. + const matchesPattern = (filename) => + !pathPattern.endsWith('/**') || matchesGlob(filename, pathPattern); + + const isIgnored = (filename) => ignoreLines.some(p => matchesGlob(filename, p)); if (event === 'push') { core.setOutput('base-ref', headBranch); @@ -233,14 +228,6 @@ jobs: const valeIncludes = valePathLines.filter(p => !p.startsWith('!')); const valeExcludes = valePathLines.filter(p => p.startsWith('!')).map(p => p.slice(1)); const matchesVale = (filename) => { - const matchesGlob = (f, pattern) => { - if (pattern.endsWith('/**')) return f.startsWith(pattern.slice(0, -3) + '/'); - if (pattern.endsWith('/*')) { - const dir = pattern.slice(0, -2); - return f.startsWith(dir + '/') && !f.slice(dir.length + 1).includes('/'); - } - return f === pattern; - }; const included = valeIncludes.length === 0 || valeIncludes.some(p => matchesGlob(filename, p)); const excluded = valeExcludes.some(p => matchesGlob(filename, p)); return included && !excluded;