Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions jupyterlab_git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,9 @@ async def status(self, path: str) -> dict:
Execute git status command & return the result.
"""
cmd = ["git", "status", "--porcelain", "-b", "-u", "-z"]
code, status, my_error = await self.__execute(cmd, cwd=path)
code, status, my_error = await self.__execute(
cmd, cwd=path, env=os.environ.copy()
)

if code != 0:
return {
Expand Down Expand Up @@ -839,7 +841,7 @@ async def branch_heads(self, path):
"refs/heads/",
]

code, output, error = await self.__execute(cmd, cwd=path)
code, output, error = await self.__execute(cmd, cwd=path, env=os.environ.copy())
if code != 0:
return {"code": code, "command": " ".join(cmd), "message": error}

Expand Down Expand Up @@ -905,7 +907,7 @@ async def branch_remotes(self, path):
"refs/remotes/",
]

code, output, error = await self.__execute(cmd, cwd=path)
code, output, error = await self.__execute(cmd, cwd=path, env=os.environ.copy())
if code != 0:
return {"code": code, "command": " ".join(cmd), "message": error}

Expand Down
122 changes: 61 additions & 61 deletions jupyterlab_git/tests/test_branch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from unittest.mock import call, patch
from unittest.mock import call, patch, ANY

import pytest

Expand Down Expand Up @@ -40,8 +40,8 @@ async def test_get_current_branch_success():
mock_execute.assert_called_once_with(
["git", "symbolic-ref", "--short", "HEAD"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -78,8 +78,8 @@ async def test_checkout_branch_noref_success():
mock_execute.assert_called_once_with(
cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -118,8 +118,8 @@ async def test_checkout_branch_noref_failure():
mock_execute.assert_called_once_with(
cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -164,8 +164,8 @@ async def test_checkout_branch_remoteref_success():
mock_execute.assert_called_once_with(
cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -207,8 +207,8 @@ async def test_checkout_branch_headsref_failure():
mock_execute.assert_called_once_with(
cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -248,8 +248,8 @@ async def test_checkout_branch_headsref_success():
mock_execute.assert_called_once_with(
cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -288,8 +288,8 @@ async def test_checkout_branch_remoteref_failure():
mock_execute.assert_called_once_with(
cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -320,8 +320,8 @@ async def test_get_branch_reference_success():
mock_execute.assert_called_once_with(
["git", "rev-parse", "--symbolic-full-name", branch],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -355,8 +355,8 @@ async def test_get_branch_reference_failure():
mock_execute.assert_called_once_with(
["git", "rev-parse", "--symbolic-full-name", branch],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -384,8 +384,8 @@ async def test_get_current_branch_failure():
mock_execute.assert_called_once_with(
["git", "symbolic-ref", "--short", "HEAD"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -418,8 +418,8 @@ async def test_get_current_branch_detached_success():
mock_execute.assert_called_once_with(
["git", "branch", "-a"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -449,8 +449,8 @@ async def test_get_current_branch_detached_failure():
mock_execute.assert_called_once_with(
["git", "branch", "-a"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -497,17 +497,17 @@ async def test_get_upstream_branch_success(branch, upstream, remotename):
"{}@{{upstream}}".format(branch),
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
),
call(
["git", "config", "--local", "branch.{}.remote".format(branch)],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -565,8 +565,8 @@ async def test_get_upstream_branch_failure(outputs, message):
call(
["git", "rev-parse", "--abbrev-ref", "blah@{upstream}"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -592,8 +592,8 @@ async def test_get_tag_success():
mock_execute.assert_called_once_with(
["git", "describe", "--tags", "abcdefghijklmnopqrstuvwxyz01234567890123"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -641,8 +641,8 @@ async def test_get_tag_failure():
call(
["git", "describe", "--tags", "blah"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -655,8 +655,8 @@ async def test_get_tag_failure():
"01234567899999abcdefghijklmnopqrstuvwxyz",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -683,8 +683,8 @@ async def test_no_tags():
mock_execute.assert_called_once_with(
["git", "describe", "--tags", "768c79ad661598889f29bdf8916f4cc488f5062a"],
cwd="/path/foo",
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -782,8 +782,8 @@ async def test_branch_success():
"refs/heads/",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -797,8 +797,8 @@ async def test_branch_success():
"refs/remotes/",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -840,8 +840,8 @@ async def test_branch_failure():
mock_execute.assert_called_once_with(
expected_cmd,
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -930,8 +930,8 @@ async def test_branch_success_detached_head():
"refs/heads/",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -940,8 +940,8 @@ async def test_branch_success_detached_head():
call(
["git", "symbolic-ref", "--short", "HEAD"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -950,8 +950,8 @@ async def test_branch_success_detached_head():
call(
["git", "branch", "-a"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -965,8 +965,8 @@ async def test_branch_success_detached_head():
"refs/remotes/",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down Expand Up @@ -1068,8 +1068,8 @@ async def test_branch_success_rebasing():
"refs/heads/",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -1078,8 +1078,8 @@ async def test_branch_success_rebasing():
call(
["git", "symbolic-ref", "--short", "HEAD"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -1088,8 +1088,8 @@ async def test_branch_success_rebasing():
call(
["git", "branch", "-a"],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand All @@ -1103,8 +1103,8 @@ async def test_branch_success_rebasing():
"refs/remotes/",
],
cwd=str(Path("/bin") / "test_curr_path"),
timeout=20,
env=None,
timeout=20.0,
env=ANY,
username=None,
password=None,
is_binary=False,
Expand Down
Loading
Loading