Skip to content

Commit 4d69781

Browse files
authoredMay 6, 2021
Merge pull request #6 from dscho/slightly-better-aggregate-title
Improve the ticket title when aggregating items
2 parents d314231 + 428bf73 commit 4d69781

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed
 

‎dist/index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -38299,8 +38299,9 @@ const run = async () => {
3829938299
const createdIssues = []
3830038300

3830138301
// Iterate
38302+
let counter = 0
3830238303
for (const item of feed.items) {
38303-
let title = `${issueTitlePrefix}${item.title}`
38304+
const title = `${issueTitlePrefix}${item.title}`
3830438305
if (titlePattern && !title.match(titlePattern)) {
3830538306
core.debug(`Feed item skipped because it does not match the title pattern (${title})`)
3830638307
continue
@@ -38342,11 +38343,19 @@ const run = async () => {
3834238343
// Create Issue
3834338344
createdIssues.push({ title, body, labels })
3834438345
} else {
38345-
title = `${issueTitlePrefix}${new Date().toTimeString()}`
38346-
createdIssues[0].title = title
38346+
if (counter === 1) {
38347+
// The title of aggregated items will be "<n>new items";
38348+
// Add the title to the body so that it does not go poof
38349+
createdIssues[0].body = `# ${createdIssues[0].title}\n\n${createdIssues[0].body}`
38350+
}
3834738351

38348-
createdIssues[0].body += `\n\n${body}`
38352+
createdIssues[0].body += `\n\n# ${title}\n\n${body}`
3834938353
}
38354+
counter++
38355+
}
38356+
38357+
if (aggregate && counter > 1) {
38358+
createdIssues[0].title = `${issueTitlePrefix}${counter} new items`
3835038359
}
3835138360

3835238361
for (const issue of createdIssues) {

‎dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎index.js

+13-4
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)
Please sign in to comment.