diff --git a/packages/python-sdk/e2b/sandbox/_git/parse.py b/packages/python-sdk/e2b/sandbox/_git/parse.py index e6cea693af..cb00c9184f 100644 --- a/packages/python-sdk/e2b/sandbox/_git/parse.py +++ b/packages/python-sdk/e2b/sandbox/_git/parse.py @@ -132,7 +132,7 @@ def parse_git_status(output: str) -> GitStatus: if is_detached or normalized_branch.startswith("HEAD"): detached = True elif "..." in normalized_branch: - branch, upstream_branch = normalized_branch.split("...") + branch, upstream_branch = normalized_branch.split("...", 1) current_branch = branch or None upstream = upstream_branch or None else: diff --git a/packages/python-sdk/tests/test_git_parse.py b/packages/python-sdk/tests/test_git_parse.py new file mode 100644 index 0000000000..07c926989c --- /dev/null +++ b/packages/python-sdk/tests/test_git_parse.py @@ -0,0 +1,11 @@ +from e2b.sandbox._git.parse import parse_git_status + + +def test_parse_git_status_branch_name_with_ellipsis(): + # Branch named "feat...v2" tracking "origin/feat...v2" — split("...") without maxsplit + # used to crash with ValueError: too many values to unpack (expected 2). + output = "## feat...v2...origin/feat...v2\n" + result = parse_git_status(output) + assert result.current_branch == "feat" + assert result.upstream == "v2...origin/feat...v2" + assert not result.detached