From 2b89aa20bcb44e322ac9369c178b68c05e1866ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 17:46:03 +0000 Subject: [PATCH 1/3] Initial plan From b28a20578847c40f596897e5ac290ed8fffe7b1a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 17:52:30 +0000 Subject: [PATCH 2/3] fix: add E005 error code to generate_git_patch.cjs (USE-001) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/generate_git_patch.cjs | 2 +- actions/setup/js/generate_git_patch.test.cjs | 38 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/generate_git_patch.cjs b/actions/setup/js/generate_git_patch.cjs index d485f8ecc59..9a77ff688f8 100644 --- a/actions/setup/js/generate_git_patch.cjs +++ b/actions/setup/js/generate_git_patch.cjs @@ -163,7 +163,7 @@ async function generateGitPatch(branchName, baseBranch, options = {}) { } else { // No remote refs available - fall through to Strategy 2 debugLog(`Strategy 1 (full): No remote refs available, falling through to Strategy 2`); - throw new Error("No remote refs available for merge-base calculation"); + throw new Error("E005: No remote refs available for merge-base calculation"); } } } diff --git a/actions/setup/js/generate_git_patch.test.cjs b/actions/setup/js/generate_git_patch.test.cjs index 01f9b2af5c5..1dd690a024f 100644 --- a/actions/setup/js/generate_git_patch.test.cjs +++ b/actions/setup/js/generate_git_patch.test.cjs @@ -324,6 +324,44 @@ describe("sanitizeBranchNameForPatch", () => { }); }); +describe("generateGitPatch - standardized error codes", () => { + let originalEnv; + + beforeEach(() => { + originalEnv = { + GITHUB_SHA: process.env.GITHUB_SHA, + GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE, + }; + }); + + afterEach(() => { + Object.keys(originalEnv).forEach(key => { + if (originalEnv[key] !== undefined) { + process.env[key] = originalEnv[key]; + } else { + delete process.env[key]; + } + }); + }); + + it("should fail gracefully and return a non-empty error string when no commits can be found", async () => { + const { generateGitPatch } = await import("./generate_git_patch.cjs"); + + process.env.GITHUB_WORKSPACE = "/tmp/nonexistent-repo"; + process.env.GITHUB_SHA = "abc123"; + + const result = await generateGitPatch("feature-branch", "main"); + + expect(result.success).toBe(false); + expect(result).toHaveProperty("error"); + // Note: E005 is used as an internal control-flow signal in Strategy 1 (full mode) + // and is caught before reaching the final return value. The conformance check + // validates the E005 code at source level via check-safe-outputs-conformance.sh. + expect(typeof result.error).toBe("string"); + expect(result.error.length).toBeGreaterThan(0); + }); +}); + describe("getPatchPath", () => { it("should return correct path format", async () => { const { getPatchPath } = await import("./generate_git_patch.cjs"); From 3e568213c2c0b36a4839d1423bc98230b2596e35 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 17:58:39 +0000 Subject: [PATCH 3/3] fix: use ERR_SYSTEM constant from error_codes.cjs in generate_git_patch.cjs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/generate_git_patch.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/generate_git_patch.cjs b/actions/setup/js/generate_git_patch.cjs index 9a77ff688f8..73752c28356 100644 --- a/actions/setup/js/generate_git_patch.cjs +++ b/actions/setup/js/generate_git_patch.cjs @@ -6,6 +6,7 @@ const path = require("path"); const { getErrorMessage } = require("./error_helpers.cjs"); const { execGitSync } = require("./git_helpers.cjs"); +const { ERR_SYSTEM } = require("./error_codes.cjs"); /** * Debug logging helper - logs to stderr when DEBUG env var matches @@ -163,7 +164,7 @@ async function generateGitPatch(branchName, baseBranch, options = {}) { } else { // No remote refs available - fall through to Strategy 2 debugLog(`Strategy 1 (full): No remote refs available, falling through to Strategy 2`); - throw new Error("E005: No remote refs available for merge-base calculation"); + throw new Error(`${ERR_SYSTEM}: No remote refs available for merge-base calculation`); } } }