Skip to content

Commit 10d983f

Browse files
cotticursoragent
andauthored
changelog: tailor failure-comment wording to missing label kind (#146)
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 <cursoragent@cursor.com>
1 parent 98927f1 commit 10d983f

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

changelog/submit/apply/scripts/post-failure-comment.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,32 @@ const { TITLE, upsertComment } = require('./comment-helper');
33
module.exports = async ({ github, context, core }) => {
44
const prNumber = parseInt(process.env.PR_NUMBER, 10);
55
const configFile = process.env.CONFIG_FILE || 'docs/changelog.yml';
6-
const labelRows = process.env.LABEL_TABLE || '';
7-
const productLabelRows = process.env.PRODUCT_LABEL_TABLE || '';
6+
const labelRows = (process.env.LABEL_TABLE || '').trim();
7+
const productLabelRows = (process.env.PRODUCT_LABEL_TABLE || '').trim();
88
const skipLabels = process.env.SKIP_LABELS || '';
99

10-
let labelSection;
11-
if (labelRows.trim()) {
12-
labelSection = [
13-
'',
14-
'🔖 Add one of these **type** labels to your PR:',
15-
'',
16-
labelRows,
17-
].join('\n');
10+
const hasTypeIssue = !!labelRows;
11+
const hasProductIssue = !!productLabelRows;
12+
13+
let headline;
14+
if (hasTypeIssue && hasProductIssue) {
15+
headline = '⚠️ **Cannot generate changelog:** required type and product labels are missing on this PR.';
16+
} else if (hasProductIssue) {
17+
headline = '⚠️ **Cannot generate changelog:** no matching product label found on this PR.';
1818
} else {
19-
labelSection = `\nAdd a type label that matches your \`pivot.types\` configuration in \`${configFile}\`.`;
19+
headline = '⚠️ **Cannot generate changelog:** no matching type label found on this PR.';
20+
}
21+
22+
const sections = [];
23+
24+
if (hasTypeIssue) {
25+
sections.push(['', '🔖 Add one of these **type** labels to your PR:', '', labelRows].join('\n'));
26+
} else if (!hasProductIssue) {
27+
sections.push(`\nAdd a type label that matches your \`pivot.types\` configuration in \`${configFile}\`.`);
2028
}
2129

22-
let productSection = '';
23-
if (productLabelRows.trim()) {
24-
productSection = [
25-
'',
26-
'📦 Add one or more **product** labels:',
27-
'',
28-
productLabelRows,
29-
].join('\n');
30+
if (hasProductIssue) {
31+
sections.push(['', '📦 Add one or more **product** labels to your PR:', '', productLabelRows].join('\n'));
3032
}
3133

3234
let skipSection;
@@ -40,9 +42,8 @@ module.exports = async ({ github, context, core }) => {
4042
const body = [
4143
TITLE,
4244
'',
43-
'⚠️ **Cannot generate changelog:** no matching type label found on this PR.',
44-
labelSection,
45-
productSection,
45+
headline,
46+
...sections,
4647
skipSection,
4748
'',
4849
`📄 See \`${configFile}\` for the full changelog configuration.`,

0 commit comments

Comments
 (0)