perf: unshallow only when necessary
This commit is contained in:
parent
9606fe7fd0
commit
873341b21c
3 changed files with 14 additions and 9 deletions
9
dist/index.js
vendored
9
dist/index.js
vendored
|
@ -171,9 +171,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
|
||||||
if (branchRemoteName == 'fork') {
|
if (branchRemoteName == 'fork') {
|
||||||
// If pushing to a fork we must fetch with 'unshallow' to avoid the following error on git push
|
// 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)
|
// ! [remote rejected] HEAD -> tests/push-branch-to-fork (shallow update not allowed)
|
||||||
yield git.fetch([`${workingBase}:${workingBase}`], baseRemote, [
|
yield git.fetch([`${workingBase}:${workingBase}`], baseRemote, ['--force'], true);
|
||||||
'--force'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If the remote is 'origin' we can git reset
|
// If the remote is 'origin' we can git reset
|
||||||
|
@ -801,14 +799,15 @@ class GitCommandManager {
|
||||||
return output.exitCode === 0;
|
return output.exitCode === 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fetch(refSpec, remoteName, options) {
|
fetch(refSpec, remoteName, options, unshallow = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const args = ['-c', 'protocol.version=2', 'fetch'];
|
const args = ['-c', 'protocol.version=2', 'fetch'];
|
||||||
if (!refSpec.some(x => x === tagsRefSpec)) {
|
if (!refSpec.some(x => x === tagsRefSpec)) {
|
||||||
args.push('--no-tags');
|
args.push('--no-tags');
|
||||||
}
|
}
|
||||||
args.push('--progress', '--no-recurse-submodules');
|
args.push('--progress', '--no-recurse-submodules');
|
||||||
if (utils.fileExistsSync(path.join(this.workingDirectory, '.git', 'shallow'))) {
|
if (unshallow &&
|
||||||
|
utils.fileExistsSync(path.join(this.workingDirectory, '.git', 'shallow'))) {
|
||||||
args.push('--unshallow');
|
args.push('--unshallow');
|
||||||
}
|
}
|
||||||
if (options) {
|
if (options) {
|
||||||
|
|
|
@ -180,9 +180,12 @@ export async function createOrUpdateBranch(
|
||||||
if (branchRemoteName == 'fork') {
|
if (branchRemoteName == 'fork') {
|
||||||
// If pushing to a fork we must fetch with 'unshallow' to avoid the following error on git push
|
// 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)
|
// ! [remote rejected] HEAD -> tests/push-branch-to-fork (shallow update not allowed)
|
||||||
await git.fetch([`${workingBase}:${workingBase}`], baseRemote, [
|
await git.fetch(
|
||||||
'--force'
|
[`${workingBase}:${workingBase}`],
|
||||||
])
|
baseRemote,
|
||||||
|
['--force'],
|
||||||
|
true
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// If the remote is 'origin' we can git reset
|
// If the remote is 'origin' we can git reset
|
||||||
await git.checkout(workingBase)
|
await git.checkout(workingBase)
|
||||||
|
|
|
@ -105,7 +105,8 @@ export class GitCommandManager {
|
||||||
async fetch(
|
async fetch(
|
||||||
refSpec: string[],
|
refSpec: string[],
|
||||||
remoteName?: string,
|
remoteName?: string,
|
||||||
options?: string[]
|
options?: string[],
|
||||||
|
unshallow = false
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const args = ['-c', 'protocol.version=2', 'fetch']
|
const args = ['-c', 'protocol.version=2', 'fetch']
|
||||||
if (!refSpec.some(x => x === tagsRefSpec)) {
|
if (!refSpec.some(x => x === tagsRefSpec)) {
|
||||||
|
@ -113,7 +114,9 @@ export class GitCommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push('--progress', '--no-recurse-submodules')
|
args.push('--progress', '--no-recurse-submodules')
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
unshallow &&
|
||||||
utils.fileExistsSync(path.join(this.workingDirectory, '.git', 'shallow'))
|
utils.fileExistsSync(path.join(this.workingDirectory, '.git', 'shallow'))
|
||||||
) {
|
) {
|
||||||
args.push('--unshallow')
|
args.push('--unshallow')
|
||||||
|
|
Loading…
Reference in a new issue