Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/daily-choice-test.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions actions/setup/js/push_repo_memory.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,15 @@ async function main() {
});

if (!matchResults.some(m => m)) {
core.error(`File does not match allowed patterns: ${normalizedRelPath}`);
core.error(`Allowed patterns: ${fileGlobFilter}`);
core.error(`Pattern test results:`);
core.warning(`Skipping file that does not match allowed patterns: ${normalizedRelPath}`);
core.debug(`Allowed patterns: ${fileGlobFilter}`);
core.debug(`Pattern test results:`);
const patternStrs = fileGlobFilter.trim().split(/\s+/).filter(Boolean);
patterns.forEach((pattern, idx) => {
core.error(` ${patternStrs[idx]} -> regex: ${pattern.source} -> ${matchResults[idx] ? "MATCH" : "NO MATCH"}`);
core.debug(` ${patternStrs[idx]} -> regex: ${pattern.source} -> ${matchResults[idx] ? "MATCH" : "NO MATCH"}`);
});
core.setFailed("File pattern validation failed");
throw new Error("File pattern validation failed");
// Skip this file instead of failing - it may be from a previous run with different patterns
return;
}
}

Expand Down
19 changes: 19 additions & 0 deletions actions/setup/js/push_repo_memory.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -981,5 +981,24 @@ describe("push_repo_memory.cjs - glob pattern security tests", () => {
expect(matches).toBe(shouldMatch);
}
});

it("should allow filtering out legacy files from previous runs", () => {
// Real-world scenario: The memory/campaigns branch had old files with incorrect
// nesting (memory/default/...) from before a bug fix. When cloning this branch,
// these old files are present alongside new correctly-structured files.
// The glob filter should match only the new files, allowing old files to be skipped.
const currentPattern = globPatternToRegex("go-file-size-reduction-project64/**");

// New files (should match)
expect(currentPattern.test("go-file-size-reduction-project64/cursor.json")).toBe(true);
expect(currentPattern.test("go-file-size-reduction-project64/metrics/2025-12-31.json")).toBe(true);

// Legacy files with incorrect nesting (should not match)
expect(currentPattern.test("memory/default/go-file-size-reduction-20610415309/metrics/2025-12-31.json")).toBe(false);
expect(currentPattern.test("memory/campaigns/go-file-size-reduction-project64/cursor.json")).toBe(false);

// This behavior allows push_repo_memory.cjs to skip legacy files instead of failing,
// enabling gradual migration from old to new structure without manual branch cleanup.
});
});
});
Loading