From 7a2cc8a3dc2491ffbcf5da372eba9e2432c8fd66 Mon Sep 17 00:00:00 2001 From: Jake Hiller Date: Thu, 25 Jun 2020 01:25:52 -0400 Subject: [PATCH] simplify comment logic --- src/comment.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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) {