-
Notifications
You must be signed in to change notification settings - Fork 362
Open
Labels
Description
Description
The status() and branch() methods in git.py use static environment inheritance instead of capturing current environment state, causing them to miss runtime environment variable changes that could be critical for Git operations.
Reproduce
In /jupyterlab_git/git.py
, the status and branch APIs execute git commands without explicitly passing environment variables:
Status API (git.py:494):
code, status, my_error = await self.__execute(cmd, cwd=path)
Branch APIs (git.py:842, git.py:908):
### In branch_heads() and branch_remotes()
code, heads, error = await self.__execute(cmd, cwd=path)
When these calls reach call_subprocess() (git.py:151):
process = subprocess.Popen(
cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, env=env
)
Since env=None, the subprocess inherits the static environment from server startup time, not the current os.environ state.
Current Broken Behavior:
JupyterLab server starts
Later during runtime:
os.environ['GIT_CONFIG'] = '/custom/.gitconfig'
os.environ['GIT_SSH_COMMAND'] = 'ssh -i /custom/key'
os.environ['GIT_TRACE'] = '1' # For debugging
These environment changes are IGNORED by:
git_instance.status() # Still uses startup environment
git_instance.branch() # Still uses startup environment
Expected behavior
Both status and branch APIs should start with a clean environment like other APIs
env = os.environ.copy()
code, status, my_error = await self.__execute(cmd, cwd=path, env=env)