mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
push-to-fork fix
This commit is contained in:
parent
53d7eb4f40
commit
810fe9fda7
2 changed files with 14 additions and 4 deletions
9
dist/index.js
vendored
9
dist/index.js
vendored
|
@ -183,8 +183,13 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
|
||||||
// This will also be true if the working base type is a commit
|
// This will also be true if the working base type is a commit
|
||||||
if (workingBase != base) {
|
if (workingBase != base) {
|
||||||
core.info(`Rebasing commits made to ${workingBaseType} '${workingBase}' on to base branch '${base}'`);
|
core.info(`Rebasing commits made to ${workingBaseType} '${workingBase}' on to base branch '${base}'`);
|
||||||
|
const fetchArgs = ['--force'];
|
||||||
|
if (branchRemoteName != 'fork') {
|
||||||
|
// If pushing to a fork we cannot shallow fetch otherwise the 'shallow update not allowed' error occurs
|
||||||
|
fetchArgs.push('--depth=1');
|
||||||
|
}
|
||||||
// Checkout the actual base
|
// Checkout the actual base
|
||||||
yield git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1']);
|
yield git.fetch([`${base}:${base}`], baseRemote, fetchArgs);
|
||||||
yield git.checkout(base);
|
yield git.checkout(base);
|
||||||
// Cherrypick commits from the temporary branch starting from the working base
|
// Cherrypick commits from the temporary branch starting from the working base
|
||||||
const commits = yield git.revList([`${workingBase}..${tempBranch}`, '.'], ['--reverse']);
|
const commits = yield git.revList([`${workingBase}..${tempBranch}`, '.'], ['--reverse']);
|
||||||
|
@ -197,7 +202,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
|
||||||
// Reset the temp branch to the working index
|
// Reset the temp branch to the working index
|
||||||
yield git.checkout(tempBranch, 'HEAD');
|
yield git.checkout(tempBranch, 'HEAD');
|
||||||
// Reset the base
|
// Reset the base
|
||||||
yield git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1']);
|
yield git.fetch([`${base}:${base}`], baseRemote, fetchArgs);
|
||||||
}
|
}
|
||||||
// Try to fetch the pull request branch
|
// Try to fetch the pull request branch
|
||||||
if (!(yield tryFetch(git, branchRemoteName, branch))) {
|
if (!(yield tryFetch(git, branchRemoteName, branch))) {
|
||||||
|
|
|
@ -199,8 +199,13 @@ export async function createOrUpdateBranch(
|
||||||
core.info(
|
core.info(
|
||||||
`Rebasing commits made to ${workingBaseType} '${workingBase}' on to base branch '${base}'`
|
`Rebasing commits made to ${workingBaseType} '${workingBase}' on to base branch '${base}'`
|
||||||
)
|
)
|
||||||
|
const fetchArgs = ['--force']
|
||||||
|
if (branchRemoteName != 'fork') {
|
||||||
|
// If pushing to a fork we cannot shallow fetch otherwise the 'shallow update not allowed' error occurs
|
||||||
|
fetchArgs.push('--depth=1')
|
||||||
|
}
|
||||||
// Checkout the actual base
|
// Checkout the actual base
|
||||||
await git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1'])
|
await git.fetch([`${base}:${base}`], baseRemote, fetchArgs)
|
||||||
await git.checkout(base)
|
await git.checkout(base)
|
||||||
// Cherrypick commits from the temporary branch starting from the working base
|
// Cherrypick commits from the temporary branch starting from the working base
|
||||||
const commits = await git.revList(
|
const commits = await git.revList(
|
||||||
|
@ -219,7 +224,7 @@ export async function createOrUpdateBranch(
|
||||||
// Reset the temp branch to the working index
|
// Reset the temp branch to the working index
|
||||||
await git.checkout(tempBranch, 'HEAD')
|
await git.checkout(tempBranch, 'HEAD')
|
||||||
// Reset the base
|
// Reset the base
|
||||||
await git.fetch([`${base}:${base}`], baseRemote, ['--force', '--depth=1'])
|
await git.fetch([`${base}:${base}`], baseRemote, fetchArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to fetch the pull request branch
|
// Try to fetch the pull request branch
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue