Skip to content

Commit 62c9ca2

Browse files
committed
Improve the ticket title when aggregating items
When aggregating items and there is a single item, it is easy: let's use the title of that single item. Otherwise, say how many items were found. This improves the ticket text substantially. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent d314231 commit 62c9ca2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ const run = async () => {
6262
const createdIssues = []
6363

6464
// Iterate
65+
let counter = 0
6566
for (const item of feed.items) {
66-
let title = `${issueTitlePrefix}${item.title}`
67+
const title = `${issueTitlePrefix}${item.title}`
6768
if (titlePattern && !title.match(titlePattern)) {
6869
core.debug(`Feed item skipped because it does not match the title pattern (${title})`)
6970
continue
@@ -105,11 +106,19 @@ const run = async () => {
105106
// Create Issue
106107
createdIssues.push({ title, body, labels })
107108
} else {
108-
title = `${issueTitlePrefix}${new Date().toTimeString()}`
109-
createdIssues[0].title = title
109+
if (counter === 1) {
110+
// The title of aggregated items will be "<n>new items";
111+
// Add the title to the body so that it does not go poof
112+
createdIssues[0].body = `# ${createdIssues[0].title}\n\n${createdIssues[0].body}`
113+
}
110114

111-
createdIssues[0].body += `\n\n${body}`
115+
createdIssues[0].body += `\n\n# ${title}\n\n${body}`
112116
}
117+
counter++
118+
}
119+
120+
if (aggregate && counter > 1) {
121+
createdIssues[0].title = `${issueTitlePrefix}${counter} new items`
113122
}
114123

115124
for (const issue of createdIssues) {

0 commit comments

Comments
 (0)