fix(shared): classify trailing-space ignore rules

This commit is contained in:
Peter Steinberger
2026-07-14 20:03:26 +01:00
parent 21515ae808
commit bfa72f8dab
2 changed files with 3 additions and 2 deletions

View File

@@ -134,7 +134,7 @@ describe("DefaultPackageManager", () => {
await writeFile(insideSkill, "# Inside\n", "utf-8");
await writeFile(ignoredSkill, "# Ignored\n", "utf-8");
await writeFile(escapedSkill, "# Ignored\n", "utf-8");
await writeFile(join(agentsSkillsRoot, "group", ".gitignore"), "ignored/\n\\!literal/\n");
await writeFile(join(agentsSkillsRoot, "group", ".gitignore"), "ignored/ \n\\!literal/\n");
await writeFile(join(outsideRoot, "SKILL.md"), "# Outside\n", "utf-8");
try {

View File

@@ -36,7 +36,8 @@ function prefixIgnorePattern(line: string, prefix: string): string {
const pattern = negated ? line.slice(1) : line;
const anchored = pattern.startsWith("/");
const normalized = anchored ? pattern.slice(1) : pattern;
const depthGlob = prefix && !anchored && !normalized.slice(0, -1).includes("/") ? "**/" : "";
const matchPattern = normalized.replace(/ +$/, "");
const depthGlob = prefix && !anchored && !matchPattern.slice(0, -1).includes("/") ? "**/" : "";
const prefixed = `${prefix}${depthGlob}${normalized}`;
return negated ? `!${prefixed}` : prefixed;
}