When base is set, fetch depth=1

This commit is contained in:
Eric Webb 2024-03-07 09:17:08 -08:00 committed by Eric Webb
parent b3a2c5d525
commit c4e548c6bd
2 changed files with 8 additions and 6 deletions

7
dist/index.js vendored
View file

@ -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))) {

View file

@ -35,7 +35,8 @@ export async function tryFetch(
): Promise<boolean> {
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