From 21cddb4736c0af319127eedcb9321ddd187057de Mon Sep 17 00:00:00 2001 From: gatzjames Date: Thu, 7 Nov 2024 15:04:19 +0100 Subject: [PATCH] Handle clone with conflicts --- packages/insomnia/src/sync/git/git-vcs.ts | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/insomnia/src/sync/git/git-vcs.ts b/packages/insomnia/src/sync/git/git-vcs.ts index c99af640b16..8d6922958b5 100644 --- a/packages/insomnia/src/sync/git/git-vcs.ts +++ b/packages/insomnia/src/sync/git/git-vcs.ts @@ -196,12 +196,24 @@ export class GitVCS { http: httpClient, repoId, }; - await git.clone({ - ...this._baseOpts, - url, - singleBranch: true, - }); - console.log(`[git] Clones repo to ${gitDirectory} from ${url}`); + try { + await git.clone({ + ...this._baseOpts, + url, + singleBranch: true, + }); + } catch (err) { + // If we there is a checkout conflict we only want to clone the repo + if (err instanceof git.Errors.CheckoutConflictError) { + await git.clone({ + ...this._baseOpts, + url, + singleBranch: true, + noCheckout: true, + }); + } + } + console.log(`[git] Cloned repo to ${gitDirectory} from ${url}`); } isInitializedForRepo(id: string) {