Don't make api call when body is empty

This commit is contained in:
Sebass van Boxel 2020-11-04 22:20:58 +01:00
parent 1c0044770b
commit 2350aa6ad6
No known key found for this signature in database
GPG key ID: A1E93D1FBDF515B7
2 changed files with 5 additions and 5 deletions

View file

@ -44,15 +44,15 @@ exports.findPreviousComment = findPreviousComment;
function updateComment(octokit, repo, comment_id, body, header, previousBody) { function updateComment(octokit, repo, comment_id, body, header, previousBody) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!body && !previousBody) 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)}` })); yield octokit.issues.updateComment(Object.assign(Object.assign({}, repo), { comment_id, body: previousBody ? `${previousBody}\n${body}` : `${body}\n${headerComment(header)}` }));
}); });
} }
exports.updateComment = updateComment; exports.updateComment = updateComment;
function createComment(octokit, repo, issue_number, body, header, previousBody) { function createComment(octokit, repo, issue_number, body, header, previousBody) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!body) if (!body && !previousBody)
core.warning('Comment body cannot be blank'); 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)}` })); yield octokit.issues.createComment(Object.assign(Object.assign({}, repo), { issue_number, body: previousBody ? `${previousBody}\n${body}` : `${body}\n${headerComment(header)}` }));
}); });
} }

View file

@ -13,7 +13,7 @@ export async function findPreviousComment(octokit, repo, issue_number, header) {
return comments.find(comment => comment.body.includes(h)); return comments.find(comment => comment.body.includes(h));
} }
export async function updateComment(octokit, repo, comment_id, body, header, previousBody?) { 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({ await octokit.issues.updateComment({
...repo, ...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?) { 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({ await octokit.issues.createComment({
...repo, ...repo,