From b20e399977475064d6c738ca9c353bfb715793a2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 29 May 2026 12:13:06 +0000 Subject: [PATCH 1/2] Initial plan From 2c1ffbd0153bf969a40e4f73852a64b3435c20bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 29 May 2026 12:22:26 +0000 Subject: [PATCH 2/2] Fix brittle non-fast-forward fallback tests Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com> --- .../js/push_to_pull_request_branch.test.cjs | 66 +++++++++++++++---- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/actions/setup/js/push_to_pull_request_branch.test.cjs b/actions/setup/js/push_to_pull_request_branch.test.cjs index 1d07ef480c1..333bcf28c69 100644 --- a/actions/setup/js/push_to_pull_request_branch.test.cjs +++ b/actions/setup/js/push_to_pull_request_branch.test.cjs @@ -1004,14 +1004,33 @@ index 0000000..abc1234 mockExec.exec.mockResolvedValueOnce(0); // git am - // pushSignedCommits: git rev-list returns one SHA so the push is attempted - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "abc123\n", stderr: "" }); // git rev-list - // pushSignedCommits: git ls-remote returns remote HEAD OID - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "remote-oid\trefs/heads/feature-branch\n", stderr: "" }); // git ls-remote - // pushSignedCommits: git log -1 returns commit message - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "Test commit\n", stderr: "" }); // git log -1 - // pushSignedCommits: git diff --name-status returns file changes - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "", stderr: "" }); // git diff --name-status (empty - no files) + const originalGetExecOutput = mockExec.getExecOutput; + mockExec.getExecOutput = vi.fn().mockImplementation(async (cmd, args) => { + const argList = Array.isArray(args) ? args : []; + if (argList[0] === "rev-parse" && argList[1] === "origin/feature-branch^{commit}") { + return { exitCode: 0, stdout: "1111111111111111111111111111111111111111\n", stderr: "" }; + } + if (argList[0] === "rev-list" && argList[1] === "--merges") { + return { exitCode: 0, stdout: "0\n", stderr: "" }; + } + if (argList[0] === "rev-list" && argList[1] === "--parents") { + return { + exitCode: 0, + stdout: "2222222222222222222222222222222222222222 1111111111111111111111111111111111111111\n", + stderr: "", + }; + } + if (argList[0] === "ls-remote" && argList[2] === "refs/heads/feature-branch") { + return { exitCode: 0, stdout: "1111111111111111111111111111111111111111\trefs/heads/feature-branch\n", stderr: "" }; + } + if (argList[0] === "log") { + return { exitCode: 0, stdout: "Test commit\n", stderr: "" }; + } + if (argList[0] === "diff-tree") { + return { exitCode: 0, stdout: "", stderr: "" }; + } + return originalGetExecOutput(cmd, args); + }); // GraphQL call fails, triggering fallback to git push mockGithub.graphql.mockRejectedValueOnce(new Error("GraphQL error: branch protection")); @@ -1041,10 +1060,33 @@ index 0000000..abc1234 mockExec.exec.mockResolvedValueOnce(0); // git am - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "abc123\n", stderr: "" }); // git rev-list - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "remote-oid\trefs/heads/feature-branch\n", stderr: "" }); // git ls-remote - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "Test commit\n", stderr: "" }); // git log -1 - mockExec.getExecOutput.mockResolvedValueOnce({ exitCode: 0, stdout: "", stderr: "" }); // git diff --name-status + const originalGetExecOutput = mockExec.getExecOutput; + mockExec.getExecOutput = vi.fn().mockImplementation(async (cmd, args) => { + const argList = Array.isArray(args) ? args : []; + if (argList[0] === "rev-parse" && argList[1] === "origin/feature-branch^{commit}") { + return { exitCode: 0, stdout: "1111111111111111111111111111111111111111\n", stderr: "" }; + } + if (argList[0] === "rev-list" && argList[1] === "--merges") { + return { exitCode: 0, stdout: "0\n", stderr: "" }; + } + if (argList[0] === "rev-list" && argList[1] === "--parents") { + return { + exitCode: 0, + stdout: "2222222222222222222222222222222222222222 1111111111111111111111111111111111111111\n", + stderr: "", + }; + } + if (argList[0] === "ls-remote" && argList[2] === "refs/heads/feature-branch") { + return { exitCode: 0, stdout: "1111111111111111111111111111111111111111\trefs/heads/feature-branch\n", stderr: "" }; + } + if (argList[0] === "log") { + return { exitCode: 0, stdout: "Test commit\n", stderr: "" }; + } + if (argList[0] === "diff-tree") { + return { exitCode: 0, stdout: "", stderr: "" }; + } + return originalGetExecOutput(cmd, args); + }); mockGithub.graphql.mockRejectedValueOnce(new Error("GraphQL error: branch protection")); mockExec.exec.mockRejectedValueOnce(new Error("! [rejected] feature-branch -> feature-branch (non-fast-forward)"));