Skip to content
Closed
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
42 changes: 42 additions & 0 deletions .github/scripts/__tests__/merge-manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,48 @@ test('evaluatePullRequest enforces max_lines_changed limits', async () => {
assert.equal(outputs.safe, 'false');
});

test('evaluatePullRequest treats ./ glob the same as root glob', async () => {
const pr = makePullRequest({
labels: [{ name: 'automerge' }, { name: 'from:codex' }, { name: 'risk:low' }],
});
const files = [{ filename: 'app.py', changes: 2 }];

const first = createCore();
const githubDot = createGithubStub({
pr,
files,
allowlist: { patterns: ['./**'], max_lines_changed: 10 },
});

await evaluatePullRequest({
github: githubDot,
core: first.core,
owner: 'octo',
repo: 'demo',
prNumber: 7,
config: {},
});

const second = createCore();
const githubRoot = createGithubStub({
pr,
files,
allowlist: { patterns: ['**'], max_lines_changed: 10 },
});

await evaluatePullRequest({
github: githubRoot,
core: second.core,
owner: 'octo',
repo: 'demo',
prNumber: 7,
config: {},
});

assert.equal(first.outputs.allowlist_ok, 'true');
assert.equal(second.outputs.allowlist_ok, 'true');
});

test('upsertDecisionComment deletes existing decision comments when body is empty', async () => {
const marker = '<!-- decision -->';
const github = createGithubStub({
Expand Down
23 changes: 16 additions & 7 deletions .github/scripts/merge_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,25 @@ function escapeRegexSegment(segment) {
return segment.replace(/([\\^$*+?.()|{}\[\]])/g, '\\$1');
}

function normalizeGlobPattern(pattern) {
let normalized = String(pattern || '').trim();
while (normalized.startsWith('./')) {
normalized = normalized.slice(2);
}
return normalized;
}

function compileGlob(pattern) {
if (patternCache.has(pattern)) {
return patternCache.get(pattern);
const normalized = normalizeGlobPattern(pattern);
if (patternCache.has(normalized)) {
return patternCache.get(normalized);
}
let regex = '';
for (let i = 0; i < pattern.length; i += 1) {
const char = pattern[i];
for (let i = 0; i < normalized.length; i += 1) {
const char = normalized[i];
if (char === '*') {
if (pattern[i + 1] === '*') {
if (pattern[i + 2] === '/') {
if (normalized[i + 1] === '*') {
if (normalized[i + 2] === '/') {
regex += '(?:.*/)?';
i += 2;
} else {
Expand All @@ -61,7 +70,7 @@ function compileGlob(pattern) {
regex += escapeRegexSegment(char);
}
const compiled = new RegExp(`^${regex}$`);
patternCache.set(pattern, compiled);
patternCache.set(normalized, compiled);
return compiled;
}

Expand Down
2 changes: 1 addition & 1 deletion .workflows-lib
Submodule .workflows-lib updated from 9bf363 to 79a432
1 change: 1 addition & 0 deletions agents/codex-266.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- bootstrap for codex on issue #266 -->
Loading