fix(policy): accept AP Jira keys in PR titles

This commit is contained in:
Adam Moussa 2026-08-10 16:46:43 -04:00
parent 123366c3f1
commit fec0d6c5f0
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View file

@ -84,7 +84,7 @@ jobs:
function validateTitle(title, isDependabot, jiraMaybeExempt) {
const errs = [];
if (title.length > 120) errs.push('Title is ' + title.length + ' chars — max 120');
const m = title.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|release)(\([^)]+\))?(!)?: (.+?)(\s+\((DEV|PLAT|SEC)-\d+\))?$/);
const m = title.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|release)(\([^)]+\))?(!)?: (.+?)(\s+\((DEV|PLAT|SEC|AP)-\d+\))?$/);
if (!m) {
errs.push('Title must match: type(scope): description (KEY-NNN). Allowed types: ' + CONV_TYPES.join(' '));
return errs;
@ -94,13 +94,13 @@ jobs:
if (desc.endsWith('.')) errs.push('Description must not end with a period');
if (!/^[a-z]/.test(desc)) errs.push('Description must start with a lowercase letter');
if (!isDependabot && !jiraSuffix && !jiraMaybeExempt) {
errs.push('Missing Jira key — expected (DEV-NNN), (PLAT-NNN), or (SEC-NNN) at end of title');
errs.push('Missing Jira key — expected (DEV-NNN), (PLAT-NNN), (SEC-NNN), or (AP-NNN) at end of title');
}
return errs;
}
function getJiraKey(title) {
const m = title.match(/\((DEV|PLAT|SEC)-(\d+)\)$/);
const m = title.match(/\((DEV|PLAT|SEC|AP)-(\d+)\)$/);
return m ? m[1] + '-' + m[2] : null;
}
@ -113,7 +113,7 @@ jobs:
errs.push('Branch "' + branch + '" must match prefix/kebab-case (no consecutive/trailing hyphens, no uppercase, one segment). Prefixes: feature fix hotfix chore docs refactor release');
return errs;
}
if (/(?:DEV|PLAT|SEC|INFRA)-\d+/i.test(m[2])) errs.push('Branch segment must not contain a Jira key');
if (/(?:DEV|PLAT|SEC|AP|INFRA)-\d+/i.test(m[2])) errs.push('Branch segment must not contain a Jira key');
return errs;
}
@ -181,7 +181,7 @@ jobs:
const desc = m[4];
if (!/^[a-z]/.test(desc)) errs.push('Commit description must start with a lowercase letter');
if (desc.endsWith('.')) errs.push('Commit description must not end with a period');
if (/\s+\((DEV|PLAT|SEC)-\d+\)$/i.test(subject)) errs.push('Commit subject must not carry a Jira key suffix — only the PR title does');
if (/\s+\((DEV|PLAT|SEC|AP)-\d+\)$/i.test(subject)) errs.push('Commit subject must not carry a Jira key suffix — only the PR title does');
return errs;
}

View file

@ -214,6 +214,7 @@ describe('getJiraKey', () => {
it('extracts DEV key', () => assert.equal(v.getJiraKey('fix: thing (DEV-42)'), 'DEV-42'));
it('extracts PLAT key', () => assert.equal(v.getJiraKey('chore: thing (PLAT-1)'), 'PLAT-1'));
it('extracts SEC key', () => assert.equal(v.getJiraKey('docs: thing (SEC-999)'), 'SEC-999'));
it('extracts AP key', () => assert.equal(v.getJiraKey('feat(frontend): scaffold (AP-4)'), 'AP-4'));
it('returns null when no key', () => assert.equal(v.getJiraKey('chore: thing'), null));
it('returns null for mid-title key', () => assert.equal(v.getJiraKey('fix (DEV-1): something'), null));
});