From c4e548c6bd72f33afe730d873c7a451a1240ec07 Mon Sep 17 00:00:00 2001 From: Eric Webb Date: Thu, 7 Mar 2024 09:17:08 -0800 Subject: [PATCH] When base is set, fetch depth=1 --- dist/index.js | 7 ++++--- src/create-or-update-branch.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index bca7be4..2827a60 100644 --- a/dist/index.js +++ b/dist/index.js @@ -68,7 +68,8 @@ function tryFetch(git, remote, branch) { return __awaiter(this, void 0, void 0, function* () { try { yield git.fetch([`${branch}:refs/remotes/${remote}/${branch}`], remote, [ - '--force' + '--force', + '--depth=1' ]); return true; } @@ -184,7 +185,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 +198,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..0fce3c4 100644 --- a/src/create-or-update-branch.ts +++ b/src/create-or-update-branch.ts @@ -35,7 +35,8 @@ export async function tryFetch( ): Promise { try { await git.fetch([`${branch}:refs/remotes/${remote}/${branch}`], remote, [ - '--force' + '--force', + '--depth=1' ]) return true } catch { @@ -200,7 +201,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 +220,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