From 02bcbbc8dab392dcbf8a005acba582e9ed12d91b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 26 Apr 2018 11:33:55 +0200 Subject: [PATCH] pick different folder names for git clone fixes #48485 --- extensions/git/src/git.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 77101cf8347..a04aba93531 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -388,8 +388,15 @@ export class Git { } async clone(url: string, parentPath: string, cancellationToken?: CancellationToken): Promise { - const folderName = decodeURI(url).replace(/^.*\//, '').replace(/\.git$/, '') || 'repository'; - const folderPath = path.join(parentPath, folderName); + let baseFolderName = decodeURI(url).replace(/^.*\//, '').replace(/\.git$/, '') || 'repository'; + let folderName = baseFolderName; + let folderPath = path.join(parentPath, folderName); + let count = 1; + + while (count < 20 && await new Promise(c => fs.exists(folderPath, c))) { + folderName = `${baseFolderName}-${count++}`; + folderPath = path.join(parentPath, folderName); + } await mkdirp(parentPath);