From 53d7eb4f401bc5c8b06c8a68b952582fe56c1982 Mon Sep 17 00:00:00 2001 From: Eric Webb Date: Tue, 12 Mar 2024 06:54:01 -0700 Subject: [PATCH] Update git.fetch calls to use depth=1 (#2810) * When base is set, fetch depth=1 * PR Feedback - remove depth=1 from tryFetch function --- dist/index.js | 4 ++-- src/create-or-update-branch.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index bca7be4..bc0bfac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -184,7 +184,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName if (workingBase != base) { core.info(`Rebasing commits made to ${workingBaseType} '${workingBase}' on to base branch '${base}'`); // Checkout the actual base - yield git.fetch([`${base}:${base}`], baseRemote, ['--force']); + yield git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1']); yield git.checkout(base); // Cherrypick commits from the temporary branch starting from the working base const commits = yield git.revList([`${workingBase}..${tempBranch}`, '.'], ['--reverse']); @@ -197,7 +197,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName // Reset the temp branch to the working index yield git.checkout(tempBranch, 'HEAD'); // Reset the base - yield git.fetch([`${base}:${base}`], baseRemote, ['--force']); + yield git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1']); } // Try to fetch the pull request branch if (!(yield tryFetch(git, branchRemoteName, branch))) { diff --git a/src/create-or-update-branch.ts b/src/create-or-update-branch.ts index 1c55ea5..b048d5d 100644 --- a/src/create-or-update-branch.ts +++ b/src/create-or-update-branch.ts @@ -200,7 +200,7 @@ export async function createOrUpdateBranch( `Rebasing commits made to ${workingBaseType} '${workingBase}' on to base branch '${base}'` ) // Checkout the actual base - await git.fetch([`${base}:${base}`], baseRemote, ['--force']) + await git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1']) await git.checkout(base) // Cherrypick commits from the temporary branch starting from the working base const commits = await git.revList( @@ -219,7 +219,7 @@ export async function createOrUpdateBranch( // Reset the temp branch to the working index await git.checkout(tempBranch, 'HEAD') // Reset the base - await git.fetch([`${base}:${base}`], baseRemote, ['--force']) + await git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1']) } // Try to fetch the pull request branch