Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-encode cwd if path does not exist #1214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion jupyterlab_git/git.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:],
Expand Down Expand Up @@ -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
)
Expand Down