From 2350aa6ad6c37625f1049a63bedd3489e94691d3 Mon Sep 17 00:00:00 2001 From: Sebass van Boxel Date: Wed, 4 Nov 2020 22:20:58 +0100 Subject: [PATCH] Don't make api call when body is empty --- lib/comment.js | 6 +++--- src/comment.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/comment.js b/lib/comment.js index 377403e..f7cfd98 100644 --- a/lib/comment.js +++ b/lib/comment.js @@ -44,15 +44,15 @@ exports.findPreviousComment = findPreviousComment; function updateComment(octokit, repo, comment_id, body, header, previousBody) { return __awaiter(this, void 0, void 0, function* () { if (!body && !previousBody) - core.warning('Comment body cannot be blank'); + return core.warning('Comment body cannot be blank'); yield octokit.issues.updateComment(Object.assign(Object.assign({}, repo), { comment_id, body: previousBody ? `${previousBody}\n${body}` : `${body}\n${headerComment(header)}` })); }); } exports.updateComment = updateComment; function createComment(octokit, repo, issue_number, body, header, previousBody) { return __awaiter(this, void 0, void 0, function* () { - if (!body) - core.warning('Comment body cannot be blank'); + if (!body && !previousBody) + return core.warning('Comment body cannot be blank'); yield octokit.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: previousBody ? `${previousBody}\n${body}` : `${body}\n${headerComment(header)}` })); }); } diff --git a/src/comment.ts b/src/comment.ts index 779f924..bed893a 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -13,7 +13,7 @@ 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?) { - if (!body && !previousBody) core.warning('Comment body cannot be blank'); + if (!body && !previousBody) return core.warning('Comment body cannot be blank'); await octokit.issues.updateComment({ ...repo, @@ -22,7 +22,7 @@ export async function updateComment(octokit, repo, comment_id, body, header, pre }); } export async function createComment(octokit, repo, issue_number, body, header, previousBody?) { - if (!body) core.warning('Comment body cannot be blank'); + if (!body && !previousBody) return core.warning('Comment body cannot be blank'); await octokit.issues.createComment({ ...repo,