From c8d9481220304e8397a064271d8a249ab133dcb7 Mon Sep 17 00:00:00 2001 From: "B. Seignovert" Date: Mon, 28 Nov 2022 17:44:32 +0100 Subject: [PATCH] Fix submodules unhandler error (#1191) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix submodules Unhandled error on clone * Set recurse submodules clone to False by default in the model handler * Make the additional argument optional in the clone handler Co-authored-by: Frédéric Collonval --- jupyterlab_git/handlers.py | 17 +++++++++++------ src/cloneCommand.ts | 3 ++- src/commandsAndMenu.tsx | 10 ++++++++-- src/model.ts | 5 ++++- src/tokens.ts | 4 +++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/jupyterlab_git/handlers.py b/jupyterlab_git/handlers.py index 6cd647d42..977ca7e9f 100644 --- a/jupyterlab_git/handlers.py +++ b/jupyterlab_git/handlers.py @@ -77,10 +77,15 @@ async def post(self, path: str = ""): Input format: { 'repo_url': 'https://github.com/path/to/myrepo', - OPTIONAL 'auth': '{ 'username': '', - 'password': '', - 'cache_credentials': true/false - }' + OPTIONAL 'auth': { + 'username': '', + 'password': '', + 'cache_credentials': true/false + }, + # Whether to version the clone (True) or copy (False) it. + OPTIONAL 'versioning': True, + # Whether to clone the submodules or not. + OPTIONAL 'submodules': False } """ data = self.get_json_body() @@ -88,8 +93,8 @@ async def post(self, path: str = ""): self.url2localpath(path), data["clone_url"], data.get("auth", None), - data["versioning"], - data["submodules"], + data.get("versioning", True), + data.get("submodules", False), ) if response["code"] != 0: diff --git a/src/cloneCommand.ts b/src/cloneCommand.ts index 993ffb5b9..51a0d5ec5 100644 --- a/src/cloneCommand.ts +++ b/src/cloneCommand.ts @@ -59,7 +59,8 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin = { { path: fileBrowserModel.path, url: result.value.url, - versioning: result.value.versioning + versioning: result.value.versioning, + submodules: result.value.submodules } ); logger.log({ diff --git a/src/commandsAndMenu.tsx b/src/commandsAndMenu.tsx index 49c3230bf..460766d1e 100644 --- a/src/commandsAndMenu.tsx +++ b/src/commandsAndMenu.tsx @@ -65,6 +65,10 @@ export interface IGitCloneArgs { * If false, this will remove the .git folder after cloning. */ versioning?: boolean; + /** + * Whether to activate git recurse submodules clone or not. + */ + submodules?: boolean; } /** @@ -1544,12 +1548,14 @@ export async function showGitOperationDialog( switch (operation) { case Operation.Clone: // eslint-disable-next-line no-case-declarations - const { path, url, versioning } = args as any as IGitCloneArgs; + const { path, url, versioning, submodules } = + args as any as IGitCloneArgs; result = await model.clone( path, url, authentication, - versioning ?? true + versioning ?? true, + submodules ?? false ); break; case Operation.Pull: diff --git a/src/model.ts b/src/model.ts index 36c04feaa..b16478b04 100644 --- a/src/model.ts +++ b/src/model.ts @@ -620,6 +620,7 @@ export class GitExtension implements IGitExtension { * @param url - Git repository URL * @param auth - remote repository authentication information * @param versioning - boolean flag of Git metadata (default true) + * @param submodules - boolean flag of Git submodules (default false) * @returns promise which resolves upon cloning a repository * * @throws {Git.GitResponseError} If the server response is not ok @@ -629,7 +630,8 @@ export class GitExtension implements IGitExtension { path: string, url: string, auth?: Git.IAuth, - versioning = true + versioning = true, + submodules = false ): Promise { return await this._taskHandler.execute( 'git:clone', @@ -640,6 +642,7 @@ export class GitExtension implements IGitExtension { { clone_url: url, versioning: versioning, + submodules: submodules, auth: auth as any } ); diff --git a/src/tokens.ts b/src/tokens.ts index c832c036f..517e9e0b6 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -233,6 +233,7 @@ export interface IGitExtension extends IDisposable { * @param url - Git repository URL * @param auth - remote repository authentication information * @param versioning - Whether to clone or download the Git repository + * @param submodules - Whether to clone recursively the Git submodules * @returns promise which resolves upon cloning a repository * * @throws {Git.GitResponseError} If the server response is not ok @@ -242,7 +243,8 @@ export interface IGitExtension extends IDisposable { path: string, url: string, auth?: Git.IAuth, - versioning?: boolean + versioning?: boolean, + submodules?: boolean ): Promise; /**