Add Git: Clone Recursively option

This patch adds a new command, Git: Clone Recursively, that adds the
--recursive option to git clone in order to also check out git
submodules.

Bug: 108381
This commit is contained in:
Jordan Bayles
2020-10-21 23:05:48 -07:00
parent 05c579b7ba
commit 3082f63523
5 changed files with 34 additions and 6 deletions

View File

@@ -373,7 +373,7 @@ export class Git {
return;
}
async clone(url: string, parentPath: string, progress: Progress<{ increment: number }>, cancellationToken?: CancellationToken): Promise<string> {
async clone(url: string, parentPath: string, progress: Progress<{ increment: number }>, cancellationToken?: CancellationToken, shouldRecurse?: boolean): Promise<string> {
let baseFolderName = decodeURI(url).replace(/[\/]+$/, '').replace(/^.*[\/\\]/, '').replace(/\.git$/, '') || 'repository';
let folderName = baseFolderName;
let folderPath = path.join(parentPath, folderName);
@@ -415,7 +415,11 @@ export class Git {
};
try {
await this.exec(parentPath, ['clone', url.includes(' ') ? encodeURI(url) : url, folderPath, '--progress'], { cancellationToken, onSpawn });
let command = ['clone', url.includes(' ') ? encodeURI(url) : url, folderPath, '--progress'];
if (shouldRecurse) {
command.push('--recursive');
}
await this.exec(parentPath, command, { cancellationToken, onSpawn });
} catch (err) {
if (err.stderr) {
err.stderr = err.stderr.replace(/^Cloning.+$/m, '').trim();