diff --git a/src/comment.ts b/src/comment.ts index 0c21a9d..aadbb18 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -2,10 +2,6 @@ function headerComment(header) { return ``; } -function removeHeaderComment(body, header) { - return body.replace(`\n${header}`, ''); -} - export async function findPreviousComment(octokit, repo, issue_number, header) { const { data: comments } = await octokit.issues.listComments({ ...repo, @@ -15,12 +11,10 @@ export async function findPreviousComment(octokit, repo, issue_number, header) { return comments.find(comment => comment.body.includes(h)); } export async function updateComment(octokit, repo, comment_id, body, header, previousBody?) { - const headerIdentifier = headerComment(header); - const updatedBody = previousBody ? `${removeHeaderComment(previousBody, headerIdentifier)}\n${body}` : body; await octokit.issues.updateComment({ ...repo, comment_id, - body: `${updatedBody}\n${headerIdentifier}` + body: previousBody ? `${previousBody}\n${body}` : `${body}\n${headerComment(header)}` }); } export async function createComment(octokit, repo, issue_number, body, header) {