From 85d94fdd64235acad5f82bb2669eb2ea3f86cc70 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:41:03 +0000 Subject: [PATCH 1/5] Initial plan From a5d36b32ca82847e1c4d408a05c297a986005d3e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:48:10 +0000 Subject: [PATCH 2/5] Changes before error encountered Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/generate_git_patch.cjs | 101 ++++++++++++++---------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/actions/setup/js/generate_git_patch.cjs b/actions/setup/js/generate_git_patch.cjs index 552e59311fd..dcae565530f 100644 --- a/actions/setup/js/generate_git_patch.cjs +++ b/actions/setup/js/generate_git_patch.cjs @@ -3,7 +3,6 @@ const fs = require("fs"); const path = require("path"); -const { execSync } = require("child_process"); const { getBaseBranch } = require("./get_base_branch.cjs"); const { getErrorMessage } = require("./error_helpers.cjs"); @@ -11,9 +10,10 @@ const { getErrorMessage } = require("./error_helpers.cjs"); /** * Generates a git patch file for the current changes * @param {string} branchName - The branch name to generate patch for - * @returns {Object} Object with patch info or error + * @param {Object} exec - The exec module from @actions/exec + * @returns {Promise} Object with patch info or error */ -function generateGitPatch(branchName) { +async function generateGitPatch(branchName, exec) { const patchPath = "/tmp/gh-aw/aw.patch"; const cwd = process.env.GITHUB_WORKSPACE || process.cwd(); const defaultBranch = process.env.DEFAULT_BRANCH || getBaseBranch(); @@ -33,33 +33,49 @@ function generateGitPatch(branchName) { if (branchName) { // Check if the branch exists locally try { - execSync(`git show-ref --verify --quiet refs/heads/${branchName}`, { cwd, encoding: "utf8" }); - - // Determine base ref for patch generation - let baseRef; - try { - // Check if origin/branchName exists - execSync(`git show-ref --verify --quiet refs/remotes/origin/${branchName}`, { cwd, encoding: "utf8" }); - baseRef = `origin/${branchName}`; - } catch { - // Use merge-base with default branch - execSync(`git fetch origin ${defaultBranch}`, { cwd, encoding: "utf8" }); - baseRef = execSync(`git merge-base origin/${defaultBranch} ${branchName}`, { cwd, encoding: "utf8" }).trim(); - } + const showRefResult = await exec.getExecOutput("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branchName}`], { + cwd, + ignoreReturnCode: true, + }); + + if (showRefResult.exitCode === 0) { + // Determine base ref for patch generation + let baseRef; + try { + // Check if origin/branchName exists + const originRefResult = await exec.getExecOutput("git", ["show-ref", "--verify", "--quiet", `refs/remotes/origin/${branchName}`], { + cwd, + ignoreReturnCode: true, + }); + + if (originRefResult.exitCode === 0) { + baseRef = `origin/${branchName}`; + } else { + // Use merge-base with default branch + await exec.getExecOutput("git", ["fetch", "origin", defaultBranch], { cwd }); + const mergeBaseResult = await exec.getExecOutput("git", ["merge-base", `origin/${defaultBranch}`, branchName], { cwd }); + baseRef = mergeBaseResult.stdout.trim(); + } + } catch { + // Use merge-base with default branch + await exec.getExecOutput("git", ["fetch", "origin", defaultBranch], { cwd }); + const mergeBaseResult = await exec.getExecOutput("git", ["merge-base", `origin/${defaultBranch}`, branchName], { cwd }); + baseRef = mergeBaseResult.stdout.trim(); + } - // Count commits to be included - const commitCount = parseInt(execSync(`git rev-list --count ${baseRef}..${branchName}`, { cwd, encoding: "utf8" }).trim(), 10); + // Count commits to be included + const commitCountResult = await exec.getExecOutput("git", ["rev-list", "--count", `${baseRef}..${branchName}`], { cwd }); + const commitCount = parseInt(commitCountResult.stdout.trim(), 10); - if (commitCount > 0) { - // Generate patch from the determined base to the branch - const patchContent = execSync(`git format-patch ${baseRef}..${branchName} --stdout`, { - cwd, - encoding: "utf8", - }); + if (commitCount > 0) { + // Generate patch from the determined base to the branch + const patchContentResult = await exec.getExecOutput("git", ["format-patch", `${baseRef}..${branchName}`, "--stdout"], { cwd }); + const patchContent = patchContentResult.stdout; - if (patchContent && patchContent.trim()) { - fs.writeFileSync(patchPath, patchContent, "utf8"); - patchGenerated = true; + if (patchContent && patchContent.trim()) { + fs.writeFileSync(patchPath, patchContent, "utf8"); + patchGenerated = true; + } } } } catch (branchError) { @@ -69,7 +85,8 @@ function generateGitPatch(branchName) { // Strategy 2: Check if commits were made to current HEAD since checkout if (!patchGenerated) { - const currentHead = execSync("git rev-parse HEAD", { cwd, encoding: "utf8" }).trim(); + const currentHeadResult = await exec.getExecOutput("git", ["rev-parse", "HEAD"], { cwd }); + const currentHead = currentHeadResult.stdout.trim(); if (!githubSha) { errorMessage = "GITHUB_SHA environment variable is not set"; @@ -78,21 +95,25 @@ function generateGitPatch(branchName) { } else { // Check if GITHUB_SHA is an ancestor of current HEAD try { - execSync(`git merge-base --is-ancestor ${githubSha} HEAD`, { cwd, encoding: "utf8" }); + const ancestorResult = await exec.getExecOutput("git", ["merge-base", "--is-ancestor", githubSha, "HEAD"], { + cwd, + ignoreReturnCode: true, + }); - // Count commits between GITHUB_SHA and HEAD - const commitCount = parseInt(execSync(`git rev-list --count ${githubSha}..HEAD`, { cwd, encoding: "utf8" }).trim(), 10); + if (ancestorResult.exitCode === 0) { + // Count commits between GITHUB_SHA and HEAD + const commitCountResult = await exec.getExecOutput("git", ["rev-list", "--count", `${githubSha}..HEAD`], { cwd }); + const commitCount = parseInt(commitCountResult.stdout.trim(), 10); - if (commitCount > 0) { - // Generate patch from GITHUB_SHA to HEAD - const patchContent = execSync(`git format-patch ${githubSha}..HEAD --stdout`, { - cwd, - encoding: "utf8", - }); + if (commitCount > 0) { + // Generate patch from GITHUB_SHA to HEAD + const patchContentResult = await exec.getExecOutput("git", ["format-patch", `${githubSha}..HEAD`, "--stdout"], { cwd }); + const patchContent = patchContentResult.stdout; - if (patchContent && patchContent.trim()) { - fs.writeFileSync(patchPath, patchContent, "utf8"); - patchGenerated = true; + if (patchContent && patchContent.trim()) { + fs.writeFileSync(patchPath, patchContent, "utf8"); + patchGenerated = true; + } } } } catch { From 4d2586f7571b102f6d16c2a355a283b37479d165 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 03:16:34 +0000 Subject: [PATCH 3/5] Convert generate_git_patch.cjs to use exec.getExecOutput and update tests Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/generate_git_patch.cjs | 6 +++--- actions/setup/js/generate_git_patch.test.cjs | 16 ++++++++-------- actions/setup/js/safe_outputs_handlers.cjs | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/actions/setup/js/generate_git_patch.cjs b/actions/setup/js/generate_git_patch.cjs index dcae565530f..3f56b39107d 100644 --- a/actions/setup/js/generate_git_patch.cjs +++ b/actions/setup/js/generate_git_patch.cjs @@ -3,6 +3,7 @@ const fs = require("fs"); const path = require("path"); +const exec = require("@actions/exec"); const { getBaseBranch } = require("./get_base_branch.cjs"); const { getErrorMessage } = require("./error_helpers.cjs"); @@ -10,10 +11,9 @@ const { getErrorMessage } = require("./error_helpers.cjs"); /** * Generates a git patch file for the current changes * @param {string} branchName - The branch name to generate patch for - * @param {Object} exec - The exec module from @actions/exec * @returns {Promise} Object with patch info or error */ -async function generateGitPatch(branchName, exec) { +async function generateGitPatch(branchName) { const patchPath = "/tmp/gh-aw/aw.patch"; const cwd = process.env.GITHUB_WORKSPACE || process.cwd(); const defaultBranch = process.env.DEFAULT_BRANCH || getBaseBranch(); @@ -47,7 +47,7 @@ async function generateGitPatch(branchName, exec) { cwd, ignoreReturnCode: true, }); - + if (originRefResult.exitCode === 0) { baseRef = `origin/${branchName}`; } else { diff --git a/actions/setup/js/generate_git_patch.test.cjs b/actions/setup/js/generate_git_patch.test.cjs index 403838e4a80..3bcca457024 100644 --- a/actions/setup/js/generate_git_patch.test.cjs +++ b/actions/setup/js/generate_git_patch.test.cjs @@ -30,7 +30,7 @@ describe("generateGitPatch", () => { const { generateGitPatch } = await import("./generate_git_patch.cjs"); - const result = generateGitPatch(null); + const result = await generateGitPatch(null); expect(result.success).toBe(false); expect(result).toHaveProperty("error"); @@ -43,7 +43,7 @@ describe("generateGitPatch", () => { process.env.GITHUB_WORKSPACE = "/tmp/nonexistent-repo"; process.env.GITHUB_SHA = "abc123"; - const result = generateGitPatch("nonexistent-branch"); + const result = await generateGitPatch("nonexistent-branch"); expect(result.success).toBe(false); expect(result).toHaveProperty("error"); @@ -57,7 +57,7 @@ describe("generateGitPatch", () => { process.env.GITHUB_SHA = "abc123"; // Even if it fails, it should try to create the directory - const result = generateGitPatch("test-branch"); + const result = await generateGitPatch("test-branch"); expect(result).toHaveProperty("patchPath"); expect(result.patchPath).toBe("/tmp/gh-aw/aw.patch"); @@ -69,7 +69,7 @@ describe("generateGitPatch", () => { process.env.GITHUB_WORKSPACE = "/tmp/nonexistent-repo"; process.env.GITHUB_SHA = "abc123"; - const result = generateGitPatch("test-branch"); + const result = await generateGitPatch("test-branch"); expect(result).toHaveProperty("success"); expect(result).toHaveProperty("patchPath"); @@ -82,7 +82,7 @@ describe("generateGitPatch", () => { process.env.GITHUB_WORKSPACE = "/tmp/nonexistent-repo"; process.env.GITHUB_SHA = "abc123"; - const result = generateGitPatch(null); + const result = await generateGitPatch(null); expect(result).toHaveProperty("success"); expect(result).toHaveProperty("patchPath"); @@ -94,7 +94,7 @@ describe("generateGitPatch", () => { process.env.GITHUB_WORKSPACE = "/tmp/nonexistent-repo"; process.env.GITHUB_SHA = "abc123"; - const result = generateGitPatch(""); + const result = await generateGitPatch(""); expect(result).toHaveProperty("success"); expect(result).toHaveProperty("patchPath"); @@ -107,7 +107,7 @@ describe("generateGitPatch", () => { process.env.GITHUB_SHA = "abc123"; process.env.DEFAULT_BRANCH = "develop"; - const result = generateGitPatch("feature-branch"); + const result = await generateGitPatch("feature-branch"); expect(result).toHaveProperty("success"); // Should attempt to use develop as default branch @@ -121,7 +121,7 @@ describe("generateGitPatch", () => { delete process.env.DEFAULT_BRANCH; process.env.GH_AW_BASE_BRANCH = "master"; - const result = generateGitPatch("feature-branch"); + const result = await generateGitPatch("feature-branch"); expect(result).toHaveProperty("success"); // Should attempt to use master as base branch diff --git a/actions/setup/js/safe_outputs_handlers.cjs b/actions/setup/js/safe_outputs_handlers.cjs index 5e3425b9f4a..2d99dffb327 100644 --- a/actions/setup/js/safe_outputs_handlers.cjs +++ b/actions/setup/js/safe_outputs_handlers.cjs @@ -185,7 +185,7 @@ function createHandlers(server, appendSafeOutput, config = {}) { * Resolves the current branch if branch is not provided or is the base branch * Generates git patch for the changes (unless allow-empty is true) */ - const createPullRequestHandler = args => { + const createPullRequestHandler = async args => { const entry = { ...args, type: "create_pull_request" }; const baseBranch = getBaseBranch(); @@ -226,7 +226,7 @@ function createHandlers(server, appendSafeOutput, config = {}) { // Generate git patch server.debug(`Generating patch for create_pull_request with branch: ${entry.branch}`); - const patchResult = generateGitPatch(entry.branch); + const patchResult = await generateGitPatch(entry.branch); if (!patchResult.success) { // Patch generation failed or patch is empty @@ -276,7 +276,7 @@ function createHandlers(server, appendSafeOutput, config = {}) { * Resolves the current branch if branch is not provided or is the base branch * Generates git patch for the changes */ - const pushToPullRequestBranchHandler = args => { + const pushToPullRequestBranchHandler = async args => { const entry = { ...args, type: "push_to_pull_request_branch" }; const baseBranch = getBaseBranch(); @@ -296,7 +296,7 @@ function createHandlers(server, appendSafeOutput, config = {}) { // Generate git patch server.debug(`Generating patch for push_to_pull_request_branch with branch: ${entry.branch}`); - const patchResult = generateGitPatch(entry.branch); + const patchResult = await generateGitPatch(entry.branch); if (!patchResult.success) { // Patch generation failed or patch is empty From 2f3a7fe9477c19eb58fb66497803e9845132fa6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 03:20:31 +0000 Subject: [PATCH 4/5] Use promisified child_process.exec instead of @actions/exec for runtime compatibility Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/generate_git_patch.cjs | 108 +++++++++++------------- 1 file changed, 47 insertions(+), 61 deletions(-) diff --git a/actions/setup/js/generate_git_patch.cjs b/actions/setup/js/generate_git_patch.cjs index 3f56b39107d..f4a2e4ab13a 100644 --- a/actions/setup/js/generate_git_patch.cjs +++ b/actions/setup/js/generate_git_patch.cjs @@ -3,7 +3,9 @@ const fs = require("fs"); const path = require("path"); -const exec = require("@actions/exec"); +const { promisify } = require("util"); +const { exec: execCallback } = require("child_process"); +const exec = promisify(execCallback); const { getBaseBranch } = require("./get_base_branch.cjs"); const { getErrorMessage } = require("./error_helpers.cjs"); @@ -33,49 +35,38 @@ async function generateGitPatch(branchName) { if (branchName) { // Check if the branch exists locally try { - const showRefResult = await exec.getExecOutput("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branchName}`], { - cwd, - ignoreReturnCode: true, - }); - - if (showRefResult.exitCode === 0) { - // Determine base ref for patch generation - let baseRef; - try { - // Check if origin/branchName exists - const originRefResult = await exec.getExecOutput("git", ["show-ref", "--verify", "--quiet", `refs/remotes/origin/${branchName}`], { - cwd, - ignoreReturnCode: true, - }); - - if (originRefResult.exitCode === 0) { - baseRef = `origin/${branchName}`; - } else { - // Use merge-base with default branch - await exec.getExecOutput("git", ["fetch", "origin", defaultBranch], { cwd }); - const mergeBaseResult = await exec.getExecOutput("git", ["merge-base", `origin/${defaultBranch}`, branchName], { cwd }); - baseRef = mergeBaseResult.stdout.trim(); - } - } catch { - // Use merge-base with default branch - await exec.getExecOutput("git", ["fetch", "origin", defaultBranch], { cwd }); - const mergeBaseResult = await exec.getExecOutput("git", ["merge-base", `origin/${defaultBranch}`, branchName], { cwd }); - baseRef = mergeBaseResult.stdout.trim(); - } + try { + await exec(`git show-ref --verify --quiet refs/heads/${branchName}`, { cwd }); + } catch (showRefError) { + // Branch doesn't exist, skip to strategy 2 + throw showRefError; + } - // Count commits to be included - const commitCountResult = await exec.getExecOutput("git", ["rev-list", "--count", `${baseRef}..${branchName}`], { cwd }); - const commitCount = parseInt(commitCountResult.stdout.trim(), 10); + // Determine base ref for patch generation + let baseRef; + try { + // Check if origin/branchName exists + await exec(`git show-ref --verify --quiet refs/remotes/origin/${branchName}`, { cwd }); + baseRef = `origin/${branchName}`; + } catch { + // Use merge-base with default branch + await exec(`git fetch origin ${defaultBranch}`, { cwd }); + const mergeBaseResult = await exec(`git merge-base origin/${defaultBranch} ${branchName}`, { cwd }); + baseRef = mergeBaseResult.stdout.trim(); + } - if (commitCount > 0) { - // Generate patch from the determined base to the branch - const patchContentResult = await exec.getExecOutput("git", ["format-patch", `${baseRef}..${branchName}`, "--stdout"], { cwd }); - const patchContent = patchContentResult.stdout; + // Count commits to be included + const commitCountResult = await exec(`git rev-list --count ${baseRef}..${branchName}`, { cwd }); + const commitCount = parseInt(commitCountResult.stdout.trim(), 10); - if (patchContent && patchContent.trim()) { - fs.writeFileSync(patchPath, patchContent, "utf8"); - patchGenerated = true; - } + if (commitCount > 0) { + // Generate patch from the determined base to the branch + const patchContentResult = await exec(`git format-patch ${baseRef}..${branchName} --stdout`, { cwd }); + const patchContent = patchContentResult.stdout; + + if (patchContent && patchContent.trim()) { + fs.writeFileSync(patchPath, patchContent, "utf8"); + patchGenerated = true; } } } catch (branchError) { @@ -85,7 +76,7 @@ async function generateGitPatch(branchName) { // Strategy 2: Check if commits were made to current HEAD since checkout if (!patchGenerated) { - const currentHeadResult = await exec.getExecOutput("git", ["rev-parse", "HEAD"], { cwd }); + const currentHeadResult = await exec("git rev-parse HEAD", { cwd }); const currentHead = currentHeadResult.stdout.trim(); if (!githubSha) { @@ -95,25 +86,20 @@ async function generateGitPatch(branchName) { } else { // Check if GITHUB_SHA is an ancestor of current HEAD try { - const ancestorResult = await exec.getExecOutput("git", ["merge-base", "--is-ancestor", githubSha, "HEAD"], { - cwd, - ignoreReturnCode: true, - }); - - if (ancestorResult.exitCode === 0) { - // Count commits between GITHUB_SHA and HEAD - const commitCountResult = await exec.getExecOutput("git", ["rev-list", "--count", `${githubSha}..HEAD`], { cwd }); - const commitCount = parseInt(commitCountResult.stdout.trim(), 10); - - if (commitCount > 0) { - // Generate patch from GITHUB_SHA to HEAD - const patchContentResult = await exec.getExecOutput("git", ["format-patch", `${githubSha}..HEAD`, "--stdout"], { cwd }); - const patchContent = patchContentResult.stdout; - - if (patchContent && patchContent.trim()) { - fs.writeFileSync(patchPath, patchContent, "utf8"); - patchGenerated = true; - } + await exec(`git merge-base --is-ancestor ${githubSha} HEAD`, { cwd }); + + // Count commits between GITHUB_SHA and HEAD + const commitCountResult = await exec(`git rev-list --count ${githubSha}..HEAD`, { cwd }); + const commitCount = parseInt(commitCountResult.stdout.trim(), 10); + + if (commitCount > 0) { + // Generate patch from GITHUB_SHA to HEAD + const patchContentResult = await exec(`git format-patch ${githubSha}..HEAD --stdout`, { cwd }); + const patchContent = patchContentResult.stdout; + + if (patchContent && patchContent.trim()) { + fs.writeFileSync(patchPath, patchContent, "utf8"); + patchGenerated = true; } } } catch { From 8bbeccd36c00b0450cac76a13f0e2f562663154e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 03:29:13 +0000 Subject: [PATCH 5/5] Use exec from github-script global when available, fallback to child_process Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/generate_git_patch.cjs | 57 ++++++++++++++++++++----- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/actions/setup/js/generate_git_patch.cjs b/actions/setup/js/generate_git_patch.cjs index f4a2e4ab13a..63df67dcc93 100644 --- a/actions/setup/js/generate_git_patch.cjs +++ b/actions/setup/js/generate_git_patch.cjs @@ -5,11 +5,46 @@ const fs = require("fs"); const path = require("path"); const { promisify } = require("util"); const { exec: execCallback } = require("child_process"); -const exec = promisify(execCallback); const { getBaseBranch } = require("./get_base_branch.cjs"); const { getErrorMessage } = require("./error_helpers.cjs"); +/** + * Execute a git command - works in both github-script and MCP server contexts + * @param {string} command - The git command to execute + * @param {Object} options - Options including cwd + * @returns {Promise<{stdout: string, stderr: string, exitCode: number}>} The result + */ +async function execGit(command, options = {}) { + const { cwd } = options; + + // When running in github-script context, exec is available as a global + if (typeof exec !== "undefined" && exec.getExecOutput) { + const args = command.split(" "); + const cmd = args[0]; + const cmdArgs = args.slice(1); + const result = await exec.getExecOutput(cmd, cmdArgs, { cwd, ignoreReturnCode: true }); + if (result.exitCode !== 0) { + const error = new Error(`Command failed: ${command}`); + // @ts-ignore - Adding exitCode property to Error + error.exitCode = result.exitCode; + throw error; + } + return result; + } + + // Fallback to promisified child_process.exec for MCP server context + const execAsync = promisify(execCallback); + try { + const result = await execAsync(command, { cwd }); + return { stdout: result.stdout, stderr: result.stderr, exitCode: 0 }; + } catch (error) { + // @ts-ignore - Adding exitCode property to Error + error.exitCode = error.code || 1; + throw error; + } +} + /** * Generates a git patch file for the current changes * @param {string} branchName - The branch name to generate patch for @@ -36,7 +71,7 @@ async function generateGitPatch(branchName) { // Check if the branch exists locally try { try { - await exec(`git show-ref --verify --quiet refs/heads/${branchName}`, { cwd }); + await execGit(`git show-ref --verify --quiet refs/heads/${branchName}`, { cwd }); } catch (showRefError) { // Branch doesn't exist, skip to strategy 2 throw showRefError; @@ -46,22 +81,22 @@ async function generateGitPatch(branchName) { let baseRef; try { // Check if origin/branchName exists - await exec(`git show-ref --verify --quiet refs/remotes/origin/${branchName}`, { cwd }); + await execGit(`git show-ref --verify --quiet refs/remotes/origin/${branchName}`, { cwd }); baseRef = `origin/${branchName}`; } catch { // Use merge-base with default branch - await exec(`git fetch origin ${defaultBranch}`, { cwd }); - const mergeBaseResult = await exec(`git merge-base origin/${defaultBranch} ${branchName}`, { cwd }); + await execGit(`git fetch origin ${defaultBranch}`, { cwd }); + const mergeBaseResult = await execGit(`git merge-base origin/${defaultBranch} ${branchName}`, { cwd }); baseRef = mergeBaseResult.stdout.trim(); } // Count commits to be included - const commitCountResult = await exec(`git rev-list --count ${baseRef}..${branchName}`, { cwd }); + const commitCountResult = await execGit(`git rev-list --count ${baseRef}..${branchName}`, { cwd }); const commitCount = parseInt(commitCountResult.stdout.trim(), 10); if (commitCount > 0) { // Generate patch from the determined base to the branch - const patchContentResult = await exec(`git format-patch ${baseRef}..${branchName} --stdout`, { cwd }); + const patchContentResult = await execGit(`git format-patch ${baseRef}..${branchName} --stdout`, { cwd }); const patchContent = patchContentResult.stdout; if (patchContent && patchContent.trim()) { @@ -76,7 +111,7 @@ async function generateGitPatch(branchName) { // Strategy 2: Check if commits were made to current HEAD since checkout if (!patchGenerated) { - const currentHeadResult = await exec("git rev-parse HEAD", { cwd }); + const currentHeadResult = await execGit("git rev-parse HEAD", { cwd }); const currentHead = currentHeadResult.stdout.trim(); if (!githubSha) { @@ -86,15 +121,15 @@ async function generateGitPatch(branchName) { } else { // Check if GITHUB_SHA is an ancestor of current HEAD try { - await exec(`git merge-base --is-ancestor ${githubSha} HEAD`, { cwd }); + await execGit(`git merge-base --is-ancestor ${githubSha} HEAD`, { cwd }); // Count commits between GITHUB_SHA and HEAD - const commitCountResult = await exec(`git rev-list --count ${githubSha}..HEAD`, { cwd }); + const commitCountResult = await execGit(`git rev-list --count ${githubSha}..HEAD`, { cwd }); const commitCount = parseInt(commitCountResult.stdout.trim(), 10); if (commitCount > 0) { // Generate patch from GITHUB_SHA to HEAD - const patchContentResult = await exec(`git format-patch ${githubSha}..HEAD --stdout`, { cwd }); + const patchContentResult = await execGit(`git format-patch ${githubSha}..HEAD --stdout`, { cwd }); const patchContent = patchContentResult.stdout; if (patchContent && patchContent.trim()) {