fix(pr-template-policy): avoid false positive on valid enhancement template banner (#3423)

This commit is contained in:
Tom Boucher
2026-05-11 22:45:33 -04:00
committed by GitHub
parent 3eb46a083c
commit 39e0113bcb
2 changed files with 27 additions and 7 deletions

View File

@@ -112,19 +112,21 @@ function evaluatePrTemplate(body, authorAssociation) {
if (!normalizedBody) {
valid = false;
reason = 'PR body is empty; a typed pull request template is required.';
} else if (includesDefaultTemplate(normalizedBody)) {
valid = false;
reason = 'PR body still contains the default wrong-template guidance.';
} else {
const match = matchingTemplate(normalizedBody);
template = match.template;
missingHeadings = match.missingHeadings;
if (!template) {
valid = false;
reason = 'PR body does not match the fix, enhancement, or feature template.';
} else if (missingHeadings.length > 0) {
if (template && missingHeadings.length === 0) {
valid = true;
} else if (template && missingHeadings.length > 0) {
valid = false;
reason = `PR body appears to use the ${template} template but is missing required headings.`;
} else if (includesDefaultTemplate(normalizedBody)) {
valid = false;
reason = 'PR body still contains the default wrong-template guidance.';
} else {
valid = false;
reason = 'PR body does not match the fix, enhancement, or feature template.';
}
}