From 88a73f42a9c54227b34deb3e088797cd3d692d0a Mon Sep 17 00:00:00 2001 From: Neha Singla Date: Wed, 16 Jul 2025 10:52:26 -0700 Subject: [PATCH 1/7] Add environment variable inheritance to git status and branch API calls --- jupyterlab_git/git.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jupyterlab_git/git.py b/jupyterlab_git/git.py index a4ae5e9e..280bf9ec 100644 --- a/jupyterlab_git/git.py +++ b/jupyterlab_git/git.py @@ -491,7 +491,7 @@ 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 +839,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 +905,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} From 6a561db5ba0050e9752baf3fcb5f77d721ad16b6 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Thu, 11 Sep 2025 10:47:53 +0200 Subject: [PATCH 2/7] Lint git.py file with black. --- jupyterlab_git/git.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jupyterlab_git/git.py b/jupyterlab_git/git.py index 280bf9ec..f2a58f09 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, env=os.environ.copy()) + code, status, my_error = await self.__execute( + cmd, cwd=path, env=os.environ.copy() + ) if code != 0: return { From c29b4df83b9f42e85a02bc4de3641794b27a55a5 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Thu, 11 Sep 2025 11:34:41 +0200 Subject: [PATCH 3/7] Try to fix a single test: test_status.py. --- jupyterlab_git/tests/test_status.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/jupyterlab_git/tests/test_status.py b/jupyterlab_git/tests/test_status.py index e531b515..a173b7fb 100644 --- a/jupyterlab_git/tests/test_status.py +++ b/jupyterlab_git/tests/test_status.py @@ -2,6 +2,8 @@ import pytest +import os + # local lib from jupyterlab_git.git import Git @@ -375,7 +377,7 @@ async def test_status(tmp_path, output, diff_output, expected): ["git", "status", "--porcelain", "-b", "-u", "-z"], cwd=str(repository), timeout=20, - env=None, + env=os.environ.copy(), username=None, password=None, is_binary=False, @@ -391,7 +393,7 @@ async def test_status(tmp_path, output, diff_output, expected): ], cwd=str(repository), timeout=20, - env=None, + env=os.environ.copy(), username=None, password=None, is_binary=False, @@ -400,7 +402,7 @@ async def test_status(tmp_path, output, diff_output, expected): ["git", "show", "--quiet", "CHERRY_PICK_HEAD"], cwd=str(repository), timeout=20, - env=None, + env=os.environ.copy(), username=None, password=None, is_binary=False, @@ -409,7 +411,7 @@ async def test_status(tmp_path, output, diff_output, expected): ["git", "show", "--quiet", "MERGE_HEAD"], cwd=str(repository), timeout=20, - env=None, + env=os.environ.copy(), username=None, password=None, is_binary=False, @@ -418,7 +420,7 @@ async def test_status(tmp_path, output, diff_output, expected): ["git", "rev-parse", "--git-path", "rebase-merge"], cwd=str(repository), timeout=20, - env=None, + env=os.environ.copy(), username=None, password=None, is_binary=False, @@ -427,7 +429,7 @@ async def test_status(tmp_path, output, diff_output, expected): ["git", "rev-parse", "--git-path", "rebase-apply"], cwd=str(repository), timeout=20, - env=None, + env=os.environ.copy(), username=None, password=None, is_binary=False, From 0e6f4697258813133847d9efbbd5317e08cce31d Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Thu, 11 Sep 2025 11:55:03 +0200 Subject: [PATCH 4/7] Try to use mock.any for env in test_status.py. Update timeout value to 20.0. --- jupyterlab_git/tests/test_status.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/jupyterlab_git/tests/test_status.py b/jupyterlab_git/tests/test_status.py index a173b7fb..93b123fa 100644 --- a/jupyterlab_git/tests/test_status.py +++ b/jupyterlab_git/tests/test_status.py @@ -1,9 +1,7 @@ -from unittest.mock import call, patch +from unittest.mock import call, patch, ANY import pytest -import os - # local lib from jupyterlab_git.git import Git @@ -376,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=os.environ.copy(), + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -392,8 +390,8 @@ async def test_status(tmp_path, output, diff_output, expected): "4b825dc642cb6eb9a060e54bf8d69288fbee4904", ], cwd=str(repository), - timeout=20, - env=os.environ.copy(), + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -401,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=os.environ.copy(), + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -410,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=os.environ.copy(), + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -419,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=os.environ.copy(), + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, @@ -428,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=os.environ.copy(), + timeout=20.0, + env=ANY, username=None, password=None, is_binary=False, From 471a476d6c09e4d5862b6e552154a9d5ed7c2e01 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Thu, 11 Sep 2025 12:03:53 +0200 Subject: [PATCH 5/7] Try to fix test_branch.py. --- jupyterlab_git/tests/test_branch.py | 122 ++++++++++++++-------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/jupyterlab_git/tests/test_branch.py b/jupyterlab_git/tests/test_branch.py index c78d62e6..cd506b4b 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, From b843590354f305ab1a373194da3e664c22b2220e Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Thu, 11 Sep 2025 13:25:28 +0200 Subject: [PATCH 6/7] Try to fix commit.spec.ts. --- ui-tests/tests/commit.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-tests/tests/commit.spec.ts b/ui-tests/tests/commit.spec.ts index f21a0abd..7077fc51 100644 --- a/ui-tests/tests/commit.spec.ts +++ b/ui-tests/tests/commit.spec.ts @@ -28,7 +28,7 @@ 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.getByTitle('another_file.txt • Modified').hover(); await page.getByRole('button', { name: 'Stage this change' }).click(); await page From 22862a5b720a805c5f4a9cb8b1376df89da9fe81 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Thu, 11 Sep 2025 14:32:59 +0200 Subject: [PATCH 7/7] Try another fix for commit.spec.ts. --- ui-tests/tests/commit.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui-tests/tests/commit.spec.ts b/ui-tests/tests/commit.spec.ts index 7077fc51..0827b0b4 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