mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
perf: unshallow only when necessary
This commit is contained in:
parent
9606fe7fd0
commit
873341b21c
3 changed files with 14 additions and 9 deletions
|
@ -180,9 +180,12 @@ export async function createOrUpdateBranch(
|
|||
if (branchRemoteName == 'fork') {
|
||||
// If pushing to a fork we must fetch with 'unshallow' to avoid the following error on git push
|
||||
// ! [remote rejected] HEAD -> tests/push-branch-to-fork (shallow update not allowed)
|
||||
await git.fetch([`${workingBase}:${workingBase}`], baseRemote, [
|
||||
'--force'
|
||||
])
|
||||
await git.fetch(
|
||||
[`${workingBase}:${workingBase}`],
|
||||
baseRemote,
|
||||
['--force'],
|
||||
true
|
||||
)
|
||||
} else {
|
||||
// If the remote is 'origin' we can git reset
|
||||
await git.checkout(workingBase)
|
||||
|
|
|
@ -105,7 +105,8 @@ export class GitCommandManager {
|
|||
async fetch(
|
||||
refSpec: string[],
|
||||
remoteName?: string,
|
||||
options?: string[]
|
||||
options?: string[],
|
||||
unshallow = false
|
||||
): Promise<void> {
|
||||
const args = ['-c', 'protocol.version=2', 'fetch']
|
||||
if (!refSpec.some(x => x === tagsRefSpec)) {
|
||||
|
@ -113,7 +114,9 @@ export class GitCommandManager {
|
|||
}
|
||||
|
||||
args.push('--progress', '--no-recurse-submodules')
|
||||
|
||||
if (
|
||||
unshallow &&
|
||||
utils.fileExistsSync(path.join(this.workingDirectory, '.git', 'shallow'))
|
||||
) {
|
||||
args.push('--unshallow')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue