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
2 changes: 1 addition & 1 deletion actions/setup/js/push_to_pull_request_branch.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async function main(config = {}) {
// Compute the target branch name based on target configuration
let pullNumber;
if (target === "triggering") {
pullNumber = context.payload?.pull_request?.number || context.payload?.issue?.number;
pullNumber = typeof context !== "undefined" ? context.payload?.pull_request?.number || context.payload?.issue?.number : undefined;

if (!pullNumber) {
return { success: false, error: 'push-to-pull-request-branch with target "triggering" requires pull request context' };
Expand Down
13 changes: 13 additions & 0 deletions actions/setup/js/push_to_pull_request_branch.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,19 @@ index 0000000..abc1234
expect(result.error).toContain("pull request context");
});

it('should fail gracefully with target "triggering" when context is undefined (MCP daemon mode)', async () => {
delete global.context;

const patchPath = createPatchFile();

const module = await loadModule();
const handler = await module.main({ target: "triggering" });
const result = await handler({ patch_path: patchPath }, {});

expect(result.success).toBe(false);
expect(result.error).toContain("pull request context");
});

it('should handle schedule event with target "*" and explicit PR number', async () => {
mockContext.eventName = "schedule";
delete mockContext.payload.pull_request;
Expand Down
Loading