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: 3 additions & 1 deletion src/lib/merge-train.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export async function validateTouchSet(
const violations: string[] = [];
for (const file of changedFiles) {
const matchesAny = touchSet.some(pattern => {
const glob = new Bun.Glob(pattern);
// Trailing slash means "this directory and everything inside it"
const normalized = pattern.endsWith('/') ? `${pattern}**` : pattern;
const glob = new Bun.Glob(normalized);
return glob.match(file);
});
if (!matchesAny) {
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/merge-train.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,19 @@ describe('validateTouchSet', () => {
expect(result.changedFiles).toContain('src/lib/deep/nested.ts');
});

it('should treat trailing slash as directory prefix glob', async () => {
await mustExec(['git', 'checkout', '-b', 'feature-trailing-slash', 'main'], testRepo.repoDir);
mkdirSync(join(testRepo.repoDir, 'ai-docs/gap-analysis'), { recursive: true });
writeFileSync(join(testRepo.repoDir, 'ai-docs/gap-analysis/AUDIT.md'), 'audit\n');
await mustExec(['git', 'add', '.'], testRepo.repoDir);
await mustExec(['git', 'commit', '-m', 'add audit file'], testRepo.repoDir);
await mustExec(['git', 'checkout', 'main'], testRepo.repoDir);

const result = await validateTouchSet('feature-trailing-slash', 'main', ['ai-docs/gap-analysis/'], { cwd: testRepo.repoDir });
expect(result.valid).toBe(true);
expect(result.changedFiles).toContain('ai-docs/gap-analysis/AUDIT.md');
});

it('should return valid when job has no changes', async () => {
await mustExec(['git', 'checkout', '-b', 'feature-no-changes', 'main'], testRepo.repoDir);
await mustExec(['git', 'commit', '--allow-empty', '-m', 'empty'], testRepo.repoDir);
Expand Down