MCPcopy
hub / github.com/firecow/gitlab-ci-local / resolveIncludeLocal

Function resolveIncludeLocal

src/parser-includes.ts:488–507  ·  view source on GitHub ↗
(pattern: string, cwd: string)

Source from the content-addressed store, hash-verified

486}
487
488export async function resolveIncludeLocal (pattern: string, cwd: string) {
489 const repoFiles = await ParserIncludes.memoLocalRepoFiles(cwd);
490
491 if (!pattern.startsWith("/")) pattern = `/${pattern}`; // Ensure pattern starts with `/`
492 pattern = `${cwd}${pattern}`;
493
494 // escape all special regex metacharacters
495 pattern = pattern.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
496
497 // `**` matches anything
498 const anything = ".*?";
499 pattern = pattern.replaceAll(String.raw`\*\*`, anything);
500
501 // `*` matches anything except for `/`
502 const anything_but_not_slash = "([^/])*?";
503 pattern = pattern.replaceAll(String.raw`\*`, anything_but_not_slash);
504
505 const re2js = RE2JS.compile(`^${pattern}`);
506 return repoFiles.filter((f: any) => re2js.matches(f));
507}
508
509export function getGitRemoteInfo (ctx: GitRemoteInfoContext, ...args: string[]) {
510 const cmdArgs = ["git", "ls-remote", ...args];

Callers 2

fetchTriggerIncludeMethod · 0.85
initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected