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) { diff --git a/pkg/workflow/js/push_to_pull_request_branch.cjs b/pkg/workflow/js/push_to_pull_request_branch.cjs index c9f11649243..3aaddde6002 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 && diffResult.stdout.trim() ? 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");