mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-19 14:35:50 +00:00
✨ minimize comment
This commit is contained in:
parent
3c38ed8cd4
commit
4bc21b7b93
5 changed files with 65 additions and 6 deletions
|
|
@ -6,7 +6,8 @@ import {
|
|||
deleteComment,
|
||||
findPreviousComment,
|
||||
getBodyOf,
|
||||
updateComment
|
||||
updateComment,
|
||||
minimizeComment
|
||||
} from "../src/comment"
|
||||
|
||||
jest.mock("@actions/core", () => ({
|
||||
|
|
@ -198,6 +199,19 @@ it("deleteComment", async () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("minimizeComment", async () => {
|
||||
const octokit = getOctokit("github-token")
|
||||
|
||||
jest.spyOn(octokit, "graphql").mockReturnValue(undefined as any)
|
||||
expect(await minimizeComment(octokit, "456", "OUTDATED")).toBeUndefined()
|
||||
expect(octokit.graphql).toBeCalledWith(expect.any(String), {
|
||||
input: {
|
||||
subjectId: "456",
|
||||
classifier: "OUTDATED"
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe("getBodyOf", () => {
|
||||
const nullPrevious = {}
|
||||
const simplePrevious = {
|
||||
|
|
|
|||
14
dist/index.js
generated
vendored
14
dist/index.js
generated
vendored
|
|
@ -35,7 +35,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getBodyOf = exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0;
|
||||
exports.getBodyOf = exports.minimizeComment = exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0;
|
||||
const core = __importStar(__nccwpck_require__(186));
|
||||
function headerComment(header) {
|
||||
return `<!-- Sticky Pull Request Comment${header} -->`;
|
||||
|
|
@ -137,6 +137,18 @@ function deleteComment(octokit, id) {
|
|||
});
|
||||
}
|
||||
exports.deleteComment = deleteComment;
|
||||
function minimizeComment(octokit, subjectId, classifier) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield octokit.graphql(`
|
||||
mutation($input: MinimizeCommentInput!) {
|
||||
minimizeComment(input: $input) {
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`, { input: { subjectId, classifier } });
|
||||
});
|
||||
}
|
||||
exports.minimizeComment = minimizeComment;
|
||||
function getBodyOf(previous, append, hideDetails) {
|
||||
var _a;
|
||||
if (!append) {
|
||||
|
|
|
|||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
14
lib/comment.js
generated
14
lib/comment.js
generated
|
|
@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getBodyOf = exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0;
|
||||
exports.getBodyOf = exports.minimizeComment = exports.deleteComment = exports.createComment = exports.updateComment = exports.findPreviousComment = void 0;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
function headerComment(header) {
|
||||
return `<!-- Sticky Pull Request Comment${header} -->`;
|
||||
|
|
@ -130,6 +130,18 @@ function deleteComment(octokit, id) {
|
|||
});
|
||||
}
|
||||
exports.deleteComment = deleteComment;
|
||||
function minimizeComment(octokit, subjectId, classifier) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield octokit.graphql(`
|
||||
mutation($input: MinimizeCommentInput!) {
|
||||
minimizeComment(input: $input) {
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`, { input: { subjectId, classifier } });
|
||||
});
|
||||
}
|
||||
exports.minimizeComment = minimizeComment;
|
||||
function getBodyOf(previous, append, hideDetails) {
|
||||
var _a;
|
||||
if (!append) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
import * as core from "@actions/core"
|
||||
import {IssueComment, Repository, User} from "@octokit/graphql-schema"
|
||||
import {
|
||||
IssueComment,
|
||||
ReportedContentClassifiers,
|
||||
Repository,
|
||||
User
|
||||
} from "@octokit/graphql-schema"
|
||||
import {GitHub} from "@actions/github/lib/utils"
|
||||
|
||||
function headerComment(header: String): string {
|
||||
|
|
@ -14,7 +19,7 @@ export async function findPreviousComment(
|
|||
},
|
||||
number: number,
|
||||
header: string
|
||||
): Promise<{body: string; id: string} | undefined> {
|
||||
): Promise<IssueComment | undefined> {
|
||||
let after = null
|
||||
let hasNextPage = true
|
||||
const h = headerComment(header)
|
||||
|
|
@ -133,6 +138,22 @@ export async function deleteComment(
|
|||
{id}
|
||||
)
|
||||
}
|
||||
export async function minimizeComment(
|
||||
octokit: InstanceType<typeof GitHub>,
|
||||
subjectId: string,
|
||||
classifier: ReportedContentClassifiers
|
||||
): Promise<void> {
|
||||
await octokit.graphql(
|
||||
`
|
||||
mutation($input: MinimizeCommentInput!) {
|
||||
minimizeComment(input: $input) {
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`,
|
||||
{input: {subjectId, classifier}}
|
||||
)
|
||||
}
|
||||
|
||||
export function getBodyOf(
|
||||
previous: {body?: string},
|
||||
|
|
|
|||
Loading…
Reference in a new issue