mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 12:31:14 +00:00
simplify comment logic
This commit is contained in:
parent
2015926b3a
commit
7a2cc8a3dc
1 changed files with 1 additions and 7 deletions
|
|
@ -2,10 +2,6 @@ function headerComment(header) {
|
|||
return `<!-- Sticky Pull Request Comment${header} -->`;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue