diff --git a/jupyterlab_git/git.py b/jupyterlab_git/git.py index 15488be99..19a2a61e7 100644 --- a/jupyterlab_git/git.py +++ b/jupyterlab_git/git.py @@ -10,7 +10,7 @@ import subprocess import traceback from typing import Dict, List, Optional -from urllib.parse import unquote +from urllib.parse import quote, unquote import nbformat import pexpect @@ -72,6 +72,9 @@ async def call_subprocess_with_authentication( env: "Optional[Dict[str, str]]" = None, ) -> "Tuple[int, str, str]": try: + if not os.path.exists(cwd): + cwd = quote(cwd, safe=":/\\") + p = pexpect.spawn( cmdline[0], cmdline[1:], @@ -111,6 +114,9 @@ def call_subprocess( cwd: "Optional[str]" = None, env: "Optional[Dict[str, str]]" = None, ) -> "Tuple[int, str, str]": + if not os.path.exists(cwd): + cwd = quote(cwd, safe=":/\\") + process = subprocess.Popen( cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, env=env )