mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-16 11:05:44 +00:00
✨ minimize comment (#472)
* ✨ minimize comment * ✨ hide, hide_and_recreate, hide_classify option * ✅ update config test
This commit is contained in:
parent
3c38ed8cd4
commit
39c5b5dc77
12 changed files with 272 additions and 16 deletions
20
src/main.ts
20
src/main.ts
|
|
@ -6,7 +6,10 @@ import {
|
|||
deleteOldComment,
|
||||
githubToken,
|
||||
header,
|
||||
hideAndRecreate,
|
||||
hideClassify,
|
||||
hideDetails,
|
||||
hideOldComment,
|
||||
pullRequestNumber,
|
||||
recreate,
|
||||
repo
|
||||
|
|
@ -16,6 +19,7 @@ import {
|
|||
deleteComment,
|
||||
findPreviousComment,
|
||||
getBodyOf,
|
||||
minimizeComment,
|
||||
updateComment
|
||||
} from "./comment"
|
||||
|
||||
|
|
@ -26,7 +30,7 @@ async function run(): Promise<undefined> {
|
|||
}
|
||||
|
||||
try {
|
||||
if (!deleteOldComment && !body) {
|
||||
if (!deleteOldComment && !hideOldComment && !body) {
|
||||
throw new Error("Either message or path input is required")
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +38,10 @@ async function run(): Promise<undefined> {
|
|||
throw new Error("delete and recreate cannot be both set to true")
|
||||
}
|
||||
|
||||
if (hideOldComment && hideAndRecreate) {
|
||||
throw new Error("hide and hide_and_recreate cannot be both set to true")
|
||||
}
|
||||
|
||||
const octokit = github.getOctokit(githubToken)
|
||||
const previous = await findPreviousComment(
|
||||
octokit,
|
||||
|
|
@ -51,6 +59,10 @@ async function run(): Promise<undefined> {
|
|||
await deleteComment(octokit, previous.id)
|
||||
return
|
||||
}
|
||||
if (hideOldComment) {
|
||||
await minimizeComment(octokit, previous.id, hideClassify)
|
||||
return
|
||||
}
|
||||
|
||||
const previousBody = getBodyOf(previous, append, hideDetails)
|
||||
if (recreate) {
|
||||
|
|
@ -66,6 +78,12 @@ async function run(): Promise<undefined> {
|
|||
return
|
||||
}
|
||||
|
||||
if (hideAndRecreate) {
|
||||
await minimizeComment(octokit, previous.id, hideClassify)
|
||||
await createComment(octokit, repo, pullRequestNumber, body, header)
|
||||
return
|
||||
}
|
||||
|
||||
await updateComment(octokit, previous.id, body, header, previousBody)
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue