Skip to content

Commit

Permalink
Fix submodules unhandler error (#1191)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
seignovert and fcollonval authored Nov 28, 2022
1 parent 224d4e6 commit c8d9481
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
17 changes: 11 additions & 6 deletions jupyterlab_git/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,24 @@ async def post(self, path: str = ""):
Input format:
{
'repo_url': 'https://github.com/path/to/myrepo',
OPTIONAL 'auth': '{ 'username': '<username>',
'password': '<password>',
'cache_credentials': true/false
}'
OPTIONAL 'auth': {
'username': '<username>',
'password': '<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()
response = await self.git.clone(
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:
Expand Down
3 changes: 2 additions & 1 deletion src/cloneCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
{
path: fileBrowserModel.path,
url: result.value.url,
versioning: result.value.versioning
versioning: result.value.versioning,
submodules: result.value.submodules
}
);
logger.log({
Expand Down
10 changes: 8 additions & 2 deletions src/commandsAndMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -1544,12 +1548,14 @@ export async function showGitOperationDialog<T>(
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:
Expand Down
5 changes: 4 additions & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -629,7 +630,8 @@ export class GitExtension implements IGitExtension {
path: string,
url: string,
auth?: Git.IAuth,
versioning = true
versioning = true,
submodules = false
): Promise<Git.IResultWithMessage> {
return await this._taskHandler.execute<Git.IResultWithMessage>(
'git:clone',
Expand All @@ -640,6 +642,7 @@ export class GitExtension implements IGitExtension {
{
clone_url: url,
versioning: versioning,
submodules: submodules,
auth: auth as any
}
);
Expand Down
4 changes: 3 additions & 1 deletion src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -242,7 +243,8 @@ export interface IGitExtension extends IDisposable {
path: string,
url: string,
auth?: Git.IAuth,
versioning?: boolean
versioning?: boolean,
submodules?: boolean
): Promise<Git.IResultWithMessage>;

/**
Expand Down

0 comments on commit c8d9481

Please sign in to comment.