Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions actions/setup/js/create_pr_review_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ async function main(config = {}) {
// Check if we're in a pull request context, or an issue comment context on a PR
const isPRContext =
context.eventName === "pull_request" ||
context.eventName === "pull_request_target" ||
context.eventName === "pull_request_review" ||
Comment on lines 107 to 111
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR-context detection is duplicated here; the repo already has a shared isPRContext(eventName, payload) helper in actions/setup/js/update_context_helpers.cjs (lines 39-46) that includes pull_request_target and issue_comment-on-PR handling. Consider using that helper instead of maintaining an inline boolean expression, to avoid future drift/inconsistencies across scripts.

Copilot uses AI. Check for mistakes.
context.eventName === "pull_request_review_comment" ||
(context.eventName === "issue_comment" && context.payload.issue && context.payload.issue.pull_request);
Expand Down
27 changes: 27 additions & 0 deletions actions/setup/js/create_pr_review_comment.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,33 @@ describe("create_pr_review_comment.cjs", () => {
expect(buffer.getBufferedCount()).toBe(0);
});

it("should succeed when target is triggering and event is pull_request_target", async () => {
global.context = {
eventName: "pull_request_target",
runId: 12345,
repo: { owner: "testowner", repo: "testrepo" },
payload: {
pull_request: { number: 99, head: { sha: "prt123abc456" } },
repository: {
html_url: "https://github.com/testowner/testrepo",
},
},
};
const handler = await createHandler({ target: "triggering" });
const message = {
type: "create_pull_request_review_comment",
path: "src/main.js",
line: 5,
body: "Review comment from pull_request_target trigger",
};
const result = await handler(message, {});

expect(result.success).toBe(true);
expect(result.buffered).toBe(true);
expect(result.pull_request_number).toBe(99);
expect(buffer.getBufferedCount()).toBe(1);
});

it("should reject comments targeting a different PR than the first comment", async () => {
// First comment sets context to PR #123
const handler = await createHandler();
Expand Down
Loading