mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-13 12:11:14 +00:00
๐ fix find issue
This commit is contained in:
parent
a57b4690ec
commit
3c38ed8cd4
5 changed files with 9 additions and 9 deletions
|
|
@ -18,9 +18,12 @@ const repo = {
|
|||
repo: "sticky-pull-request-comment"
|
||||
}
|
||||
it("findPreviousComment", async () => {
|
||||
const authenticatedUser = {
|
||||
const authenticatedBotUser = {
|
||||
login: "github-actions[bot]"
|
||||
}
|
||||
const authenticatedUser = {
|
||||
login: "github-actions"
|
||||
}
|
||||
const otherUser = {
|
||||
login: "some-user"
|
||||
}
|
||||
|
|
@ -64,7 +67,7 @@ it("findPreviousComment", async () => {
|
|||
]
|
||||
const octokit = getOctokit("github-token")
|
||||
jest.spyOn(octokit, "graphql").mockResolvedValue({
|
||||
viewer: authenticatedUser,
|
||||
viewer: authenticatedBotUser,
|
||||
repository: {
|
||||
pullRequest: {
|
||||
comments: {
|
||||
|
|
|
|||
3
dist/index.js
generated
vendored
3
dist/index.js
generated
vendored
|
|
@ -70,14 +70,13 @@ function findPreviousComment(octokit, repo, number, header) {
|
|||
}
|
||||
}
|
||||
`, Object.assign(Object.assign({}, repo), { after, number }));
|
||||
core.warning(JSON.stringify(data));
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const viewer = data.viewer;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const repository = data.repository;
|
||||
const target = (_c = (_b = (_a = repository.pullRequest) === null || _a === void 0 ? void 0 : _a.comments) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.find((node) => {
|
||||
var _a, _b;
|
||||
return ((_a = node === null || node === void 0 ? void 0 : node.author) === null || _a === void 0 ? void 0 : _a.login) === viewer.login &&
|
||||
return ((_a = node === null || node === void 0 ? void 0 : node.author) === null || _a === void 0 ? void 0 : _a.login) === viewer.login.replace("[bot]", "") &&
|
||||
!(node === null || node === void 0 ? void 0 : node.isMinimized) &&
|
||||
((_b = node === null || node === void 0 ? void 0 : node.body) === null || _b === void 0 ? void 0 : _b.includes(h));
|
||||
});
|
||||
|
|
|
|||
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
3
lib/comment.js
generated
3
lib/comment.js
generated
|
|
@ -63,14 +63,13 @@ function findPreviousComment(octokit, repo, number, header) {
|
|||
}
|
||||
}
|
||||
`, Object.assign(Object.assign({}, repo), { after, number }));
|
||||
core.warning(JSON.stringify(data));
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const viewer = data.viewer;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const repository = data.repository;
|
||||
const target = (_c = (_b = (_a = repository.pullRequest) === null || _a === void 0 ? void 0 : _a.comments) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.find((node) => {
|
||||
var _a, _b;
|
||||
return ((_a = node === null || node === void 0 ? void 0 : node.author) === null || _a === void 0 ? void 0 : _a.login) === viewer.login &&
|
||||
return ((_a = node === null || node === void 0 ? void 0 : node.author) === null || _a === void 0 ? void 0 : _a.login) === viewer.login.replace("[bot]", "") &&
|
||||
!(node === null || node === void 0 ? void 0 : node.isMinimized) &&
|
||||
((_b = node === null || node === void 0 ? void 0 : node.body) === null || _b === void 0 ? void 0 : _b.includes(h));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,14 +45,13 @@ export async function findPreviousComment(
|
|||
`,
|
||||
{...repo, after, number}
|
||||
)
|
||||
core.warning(JSON.stringify(data))
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const viewer = data.viewer as User
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
const repository = data.repository as Repository
|
||||
const target = repository.pullRequest?.comments?.nodes?.find(
|
||||
(node: IssueComment | null | undefined) =>
|
||||
node?.author?.login === viewer.login &&
|
||||
node?.author?.login === viewer.login.replace("[bot]", "") &&
|
||||
!node?.isMinimized &&
|
||||
node?.body?.includes(h)
|
||||
)
|
||||
|
|
|
|||
Loadingโฆ
Reference in a new issue