From c08b017f2a33025ecdc8ae9845176259df90ab23 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Tue, 12 May 2026 05:19:30 -0300 Subject: [PATCH] changelog: tailor failure-comment wording to missing label kind The post-failure-comment script always announced "no matching type label found on this PR". Now that `changelog evaluate-pr` can route a missing product label through the same comment-failure path, the headline becomes misleading when only the product label is missing. Pick the headline based on which label tables are populated: type-only, product-only, or both. The per-section formatting and the skip-labels section are unchanged. Co-authored-by: Cursor --- .../apply/scripts/post-failure-comment.js | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/changelog/submit/apply/scripts/post-failure-comment.js b/changelog/submit/apply/scripts/post-failure-comment.js index f77fb32..41ee66f 100644 --- a/changelog/submit/apply/scripts/post-failure-comment.js +++ b/changelog/submit/apply/scripts/post-failure-comment.js @@ -3,30 +3,32 @@ const { TITLE, upsertComment } = require('./comment-helper'); module.exports = async ({ github, context, core }) => { const prNumber = parseInt(process.env.PR_NUMBER, 10); const configFile = process.env.CONFIG_FILE || 'docs/changelog.yml'; - const labelRows = process.env.LABEL_TABLE || ''; - const productLabelRows = process.env.PRODUCT_LABEL_TABLE || ''; + const labelRows = (process.env.LABEL_TABLE || '').trim(); + const productLabelRows = (process.env.PRODUCT_LABEL_TABLE || '').trim(); const skipLabels = process.env.SKIP_LABELS || ''; - let labelSection; - if (labelRows.trim()) { - labelSection = [ - '', - '🔖 Add one of these **type** labels to your PR:', - '', - labelRows, - ].join('\n'); + const hasTypeIssue = !!labelRows; + const hasProductIssue = !!productLabelRows; + + let headline; + if (hasTypeIssue && hasProductIssue) { + headline = '⚠️ **Cannot generate changelog:** required type and product labels are missing on this PR.'; + } else if (hasProductIssue) { + headline = '⚠️ **Cannot generate changelog:** no matching product label found on this PR.'; } else { - labelSection = `\nAdd a type label that matches your \`pivot.types\` configuration in \`${configFile}\`.`; + headline = '⚠️ **Cannot generate changelog:** no matching type label found on this PR.'; + } + + const sections = []; + + if (hasTypeIssue) { + sections.push(['', '🔖 Add one of these **type** labels to your PR:', '', labelRows].join('\n')); + } else if (!hasProductIssue) { + sections.push(`\nAdd a type label that matches your \`pivot.types\` configuration in \`${configFile}\`.`); } - let productSection = ''; - if (productLabelRows.trim()) { - productSection = [ - '', - '📦 Add one or more **product** labels:', - '', - productLabelRows, - ].join('\n'); + if (hasProductIssue) { + sections.push(['', '📦 Add one or more **product** labels to your PR:', '', productLabelRows].join('\n')); } let skipSection; @@ -40,9 +42,8 @@ module.exports = async ({ github, context, core }) => { const body = [ TITLE, '', - '⚠️ **Cannot generate changelog:** no matching type label found on this PR.', - labelSection, - productSection, + headline, + ...sections, skipSection, '', `📄 See \`${configFile}\` for the full changelog configuration.`,