diff --git a/jupyterlab_git/git.py b/jupyterlab_git/git.py index a4ae5e9e8..f2a58f09a 100644 --- a/jupyterlab_git/git.py +++ b/jupyterlab_git/git.py @@ -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 { @@ -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} @@ -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} diff --git a/jupyterlab_git/tests/test_branch.py b/jupyterlab_git/tests/test_branch.py index c78d62e66..cd506b4b0 100644 --- a/jupyterlab_git/tests/test_branch.py +++ b/jupyterlab_git/tests/test_branch.py @@ -1,5 +1,5 @@ from pathlib import Path -from unittest.mock import call, patch +from unittest.mock import call, patch, ANY import pytest @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -497,8 +497,8 @@ 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, @@ -506,8 +506,8 @@ async def test_get_upstream_branch_success(branch, upstream, remotename): 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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/jupyterlab_git/tests/test_status.py b/jupyterlab_git/tests/test_status.py index e531b5152..93b123fa5 100644 --- a/jupyterlab_git/tests/test_status.py +++ b/jupyterlab_git/tests/test_status.py @@ -1,4 +1,4 @@ -from unittest.mock import call, patch +from unittest.mock import call, patch, ANY import pytest @@ -374,8 +374,8 @@ async def test_status(tmp_path, output, diff_output, expected): call( ["git", "status", "--porcelain", "-b", "-u", "-z"], cwd=str(repository), - timeout=20, - env=None, + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -390,8 +390,8 @@ async def test_status(tmp_path, output, diff_output, expected): "4b825dc642cb6eb9a060e54bf8d69288fbee4904", ], cwd=str(repository), - timeout=20, - env=None, + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -399,8 +399,8 @@ async def test_status(tmp_path, output, diff_output, expected): call( ["git", "show", "--quiet", "CHERRY_PICK_HEAD"], cwd=str(repository), - timeout=20, - env=None, + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -408,8 +408,8 @@ async def test_status(tmp_path, output, diff_output, expected): call( ["git", "show", "--quiet", "MERGE_HEAD"], cwd=str(repository), - timeout=20, - env=None, + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -417,8 +417,8 @@ async def test_status(tmp_path, output, diff_output, expected): call( ["git", "rev-parse", "--git-path", "rebase-merge"], cwd=str(repository), - timeout=20, - env=None, + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -426,8 +426,8 @@ async def test_status(tmp_path, output, diff_output, expected): call( ["git", "rev-parse", "--git-path", "rebase-apply"], cwd=str(repository), - timeout=20, - env=None, + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, diff --git a/ui-tests/tests/commit.spec.ts b/ui-tests/tests/commit.spec.ts index f21a0abd0..0827b0b49 100644 --- a/ui-tests/tests/commit.spec.ts +++ b/ui-tests/tests/commit.spec.ts @@ -28,7 +28,8 @@ test.describe('Commit', () => { await page.keyboard.press('Control+s'); await page.getByRole('tab', { name: 'Git' }).click(); - await page.getByTitle('another_file.txt • Modified').hover(); + await page.waitForSelector('[title="another_file.txt • Modified"]'); + await page.locator('[title="another_file.txt • Modified"]').hover(); await page.getByRole('button', { name: 'Stage this change' }).click(); await page