This commit is contained in:
Jake Hiller 2020-06-25 01:28:21 -04:00
parent 7a2cc8a3dc
commit 8c58ada506

View file

@ -13,9 +13,6 @@ exports.createComment = exports.updateComment = exports.findPreviousComment = vo
function headerComment(header) {
return `<!-- Sticky Pull Request Comment${header} -->`;
}
function removeHeaderComment(body, header) {
return body.replace(`\n${header}`, '');
}
function findPreviousComment(octokit, repo, issue_number, header) {
return __awaiter(this, void 0, void 0, function* () {
const { data: comments } = yield octokit.issues.listComments(Object.assign(Object.assign({}, repo), { issue_number }));
@ -26,9 +23,7 @@ function findPreviousComment(octokit, repo, issue_number, header) {
exports.findPreviousComment = findPreviousComment;
function updateComment(octokit, repo, comment_id, body, header, previousBody) {
return __awaiter(this, void 0, void 0, function* () {
const headerIdentifier = headerComment(header);
const updatedBody = previousBody ? `${removeHeaderComment(previousBody, headerIdentifier)}\n${body}` : body;
yield octokit.issues.updateComment(Object.assign(Object.assign({}, repo), { comment_id, body: `${updatedBody}\n${headerIdentifier}` }));
yield octokit.issues.updateComment(Object.assign(Object.assign({}, repo), { comment_id, body: previousBody ? `${previousBody}\n${body}` : `${body}\n${headerComment(header)}` }));
});
}
exports.updateComment = updateComment;