From f445a48d31a46cc470f97e3ca9b984b172206eb1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:28:28 +0000 Subject: [PATCH 1/4] Initial plan From 8c5ad99d567f8769b3efee50ff315272baf728b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:33:12 +0000 Subject: [PATCH 2/4] Plan: Add enhanced logging to push_to_pull_request_branch.cjs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../changeset-generator.firewall.lock.yml | 19 ++++++++----------- .github/workflows/mergefest.lock.yml | 19 ++++++++----------- .github/workflows/poem-bot.lock.yml | 19 ++++++++----------- .github/workflows/tidy.lock.yml | 19 ++++++++----------- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/.github/workflows/changeset-generator.firewall.lock.yml b/.github/workflows/changeset-generator.firewall.lock.yml index d47fdf66bbf..619acb11e1b 100644 --- a/.github/workflows/changeset-generator.firewall.lock.yml +++ b/.github/workflows/changeset-generator.firewall.lock.yml @@ -4955,17 +4955,14 @@ jobs: const patchContent = fs.readFileSync("/tmp/gh-aw/aw.patch", "utf8"); if (patchContent.includes("Failed to generate patch")) { const message = "Patch file contains error message - cannot push without changes"; - switch (ifNoChanges) { - case "error": - core.setFailed(message); - return; - case "ignore": - return; - case "warn": - default: - core.info(message); - return; - } + core.error("Patch file generation failed - this is an error condition that requires investigation"); + core.error(`Patch file location: /tmp/gh-aw/aw.patch`); + core.error(`Patch file size: ${Buffer.byteLength(patchContent, "utf8")} bytes`); + const previewLength = Math.min(500, patchContent.length); + core.error(`Patch file preview (first ${previewLength} characters):`); + core.error(patchContent.substring(0, previewLength)); + core.setFailed(message); + return; } const isEmpty = !patchContent || !patchContent.trim(); if (!isEmpty) { diff --git a/.github/workflows/mergefest.lock.yml b/.github/workflows/mergefest.lock.yml index 02d91250825..777b28c2bc5 100644 --- a/.github/workflows/mergefest.lock.yml +++ b/.github/workflows/mergefest.lock.yml @@ -4642,17 +4642,14 @@ jobs: const patchContent = fs.readFileSync("/tmp/gh-aw/aw.patch", "utf8"); if (patchContent.includes("Failed to generate patch")) { const message = "Patch file contains error message - cannot push without changes"; - switch (ifNoChanges) { - case "error": - core.setFailed(message); - return; - case "ignore": - return; - case "warn": - default: - core.info(message); - return; - } + core.error("Patch file generation failed - this is an error condition that requires investigation"); + core.error(`Patch file location: /tmp/gh-aw/aw.patch`); + core.error(`Patch file size: ${Buffer.byteLength(patchContent, "utf8")} bytes`); + const previewLength = Math.min(500, patchContent.length); + core.error(`Patch file preview (first ${previewLength} characters):`); + core.error(patchContent.substring(0, previewLength)); + core.setFailed(message); + return; } const isEmpty = !patchContent || !patchContent.trim(); if (!isEmpty) { diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index 98b78553b13..afe2d83720d 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -6445,17 +6445,14 @@ jobs: const patchContent = fs.readFileSync("/tmp/gh-aw/aw.patch", "utf8"); if (patchContent.includes("Failed to generate patch")) { const message = "Patch file contains error message - cannot push without changes"; - switch (ifNoChanges) { - case "error": - core.setFailed(message); - return; - case "ignore": - return; - case "warn": - default: - core.info(message); - return; - } + core.error("Patch file generation failed - this is an error condition that requires investigation"); + core.error(`Patch file location: /tmp/gh-aw/aw.patch`); + core.error(`Patch file size: ${Buffer.byteLength(patchContent, "utf8")} bytes`); + const previewLength = Math.min(500, patchContent.length); + core.error(`Patch file preview (first ${previewLength} characters):`); + core.error(patchContent.substring(0, previewLength)); + core.setFailed(message); + return; } const isEmpty = !patchContent || !patchContent.trim(); if (!isEmpty) { diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index 017892cae5f..db11190bf65 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -4949,17 +4949,14 @@ jobs: const patchContent = fs.readFileSync("/tmp/gh-aw/aw.patch", "utf8"); if (patchContent.includes("Failed to generate patch")) { const message = "Patch file contains error message - cannot push without changes"; - switch (ifNoChanges) { - case "error": - core.setFailed(message); - return; - case "ignore": - return; - case "warn": - default: - core.info(message); - return; - } + core.error("Patch file generation failed - this is an error condition that requires investigation"); + core.error(`Patch file location: /tmp/gh-aw/aw.patch`); + core.error(`Patch file size: ${Buffer.byteLength(patchContent, "utf8")} bytes`); + const previewLength = Math.min(500, patchContent.length); + core.error(`Patch file preview (first ${previewLength} characters):`); + core.error(patchContent.substring(0, previewLength)); + core.setFailed(message); + return; } const isEmpty = !patchContent || !patchContent.trim(); if (!isEmpty) { From 104a23cd4eec1de07fcf9c0cc248a9fdfeb7ea4e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:35:32 +0000 Subject: [PATCH 3/4] Add enhanced diagnostic logging to push_to_pull_request_branch.cjs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../js/push_to_pull_request_branch.cjs | 27 ++++++++++--- .../js/push_to_pull_request_branch.test.cjs | 38 ++++++++++++++++++- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/pkg/workflow/js/push_to_pull_request_branch.cjs b/pkg/workflow/js/push_to_pull_request_branch.cjs index c9f11649243..0314c494de1 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.cjs @@ -303,11 +303,11 @@ async function main() { core.info(`Patch modified with commit title suffix: "${commitTitleSuffix}"`); } - // Log first 500 lines of patch for debugging + // Log first 100 lines of patch for debugging const finalPatchContent = fs.readFileSync("/tmp/gh-aw/aw.patch", "utf8"); const patchLines = finalPatchContent.split("\n"); - const previewLines = patchLines.slice(0, 500).join("\n"); - core.info(`Patch preview (first ${Math.min(500, patchLines.length)} of ${patchLines.length} lines):\n${previewLines}`); + const previewLines = patchLines.slice(0, 100).join("\n"); + core.info(`Patch preview (first ${Math.min(100, patchLines.length)} of ${patchLines.length} lines):\n${previewLines}`); // Patches are created with git format-patch, so use git am to apply them await exec.exec("git am /tmp/gh-aw/aw.patch"); @@ -328,10 +328,25 @@ async function main() { core.info("Git status output:"); core.info(statusResult.stdout); + // Log recent commits for context + const logResult = await exec.getExecOutput("git", ["log", "--oneline", "-5"]); + core.info("Recent commits (last 5):"); + core.info(logResult.stdout); + + // Log uncommitted changes + const diffResult = await exec.getExecOutput("git", ["diff", "HEAD"]); + core.info("Uncommitted changes:"); + core.info(diffResult.stdout || "(no uncommitted changes)"); + // Log the failed patch diff - const patchResult = await exec.getExecOutput("git", ["am", "--show-current-patch=diff"]); - core.info("Failed patch content:"); - core.info(patchResult.stdout); + const patchDiffResult = await exec.getExecOutput("git", ["am", "--show-current-patch=diff"]); + core.info("Failed patch diff:"); + core.info(patchDiffResult.stdout); + + // Log the full failed patch for complete context + const patchFullResult = await exec.getExecOutput("git", ["am", "--show-current-patch"]); + core.info("Failed patch (full):"); + core.info(patchFullResult.stdout); } catch (investigateError) { core.warning( `Failed to investigate patch failure: ${investigateError instanceof Error ? investigateError.message : String(investigateError)}` diff --git a/pkg/workflow/js/push_to_pull_request_branch.test.cjs b/pkg/workflow/js/push_to_pull_request_branch.test.cjs index 6aa33d99737..5e3d56e11b0 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.test.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.test.cjs @@ -1044,6 +1044,24 @@ Subject: Add new feature }); } + // Handle git log investigation + if (command === "git" && args && args[0] === "log" && args[1] === "--oneline" && args[2] === "-5") { + return Promise.resolve({ + exitCode: 0, + stdout: "abc123 Latest commit\ndef456 Previous commit\n", + stderr: "", + }); + } + + // Handle git diff HEAD investigation + if (command === "git" && args && args[0] === "diff" && args[1] === "HEAD") { + return Promise.resolve({ + exitCode: 0, + stdout: "diff --git a/modified.txt b/modified.txt\n+modified content\n", + stderr: "", + }); + } + // Handle git am --show-current-patch=diff investigation if (command === "git" && args && args[0] === "am" && args[1] === "--show-current-patch=diff") { return Promise.resolve({ @@ -1053,6 +1071,15 @@ Subject: Add new feature }); } + // Handle git am --show-current-patch investigation + if (command === "git" && args && args[0] === "am" && args[1] === "--show-current-patch") { + return Promise.resolve({ + exitCode: 0, + stdout: "From abc123 Mon Sep 17 00:00:00 2001\nSubject: [PATCH] Add feature\n", + stderr: "", + }); + } + return Promise.resolve({ exitCode: 0, stdout: "", @@ -1068,14 +1095,23 @@ Subject: Add new feature // Verify investigation commands were called expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["status"]); + expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["log", "--oneline", "-5"]); + expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["diff", "HEAD"]); expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["am", "--show-current-patch=diff"]); + expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["am", "--show-current-patch"]); // Verify investigation logs expect(mockCore.info).toHaveBeenCalledWith("Investigating patch failure..."); expect(mockCore.info).toHaveBeenCalledWith("Git status output:"); expect(mockCore.info).toHaveBeenCalledWith("On branch feature-branch\nYour branch is up to date\n"); - expect(mockCore.info).toHaveBeenCalledWith("Failed patch content:"); + expect(mockCore.info).toHaveBeenCalledWith("Recent commits (last 5):"); + expect(mockCore.info).toHaveBeenCalledWith("abc123 Latest commit\ndef456 Previous commit\n"); + expect(mockCore.info).toHaveBeenCalledWith("Uncommitted changes:"); + expect(mockCore.info).toHaveBeenCalledWith("diff --git a/modified.txt b/modified.txt\n+modified content\n"); + expect(mockCore.info).toHaveBeenCalledWith("Failed patch diff:"); expect(mockCore.info).toHaveBeenCalledWith("diff --git a/conflicting.txt b/conflicting.txt\n+conflicting line\n"); + expect(mockCore.info).toHaveBeenCalledWith("Failed patch (full):"); + expect(mockCore.info).toHaveBeenCalledWith("From abc123 Mon Sep 17 00:00:00 2001\nSubject: [PATCH] Add feature\n"); // Verify setFailed was called expect(mockCore.setFailed).toHaveBeenCalledWith("Failed to apply patch"); From 1274a5e90a46190d7b9b2be00b681cc4d0ed9109 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:38:00 +0000 Subject: [PATCH 4/4] Improve null/empty check for uncommitted changes log Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/js/push_to_pull_request_branch.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/workflow/js/push_to_pull_request_branch.cjs b/pkg/workflow/js/push_to_pull_request_branch.cjs index 0314c494de1..3aaddde6002 100644 --- a/pkg/workflow/js/push_to_pull_request_branch.cjs +++ b/pkg/workflow/js/push_to_pull_request_branch.cjs @@ -336,7 +336,7 @@ async function main() { // Log uncommitted changes const diffResult = await exec.getExecOutput("git", ["diff", "HEAD"]); core.info("Uncommitted changes:"); - core.info(diffResult.stdout || "(no uncommitted changes)"); + core.info(diffResult.stdout && diffResult.stdout.trim() ? diffResult.stdout : "(no uncommitted changes)"); // Log the failed patch diff const patchDiffResult = await exec.getExecOutput("git", ["am", "--show-current-patch=diff"]);