Skip to content

Commit 80f359f

Browse files
authored
Bug Fix: Replace lstrip with replace function (#849)
* Replace lstrip with replace function * replace only first occurrence of remote * add unit test * make formatter happy
1 parent e3cae9e commit 80f359f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

jupyterlab_git/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ async def get_upstream_branch(self, current_path, branch_name):
11041104
return {"code": code, "command": " ".join(command), "message": error}
11051105

11061106
remote_name = output.strip()
1107-
remote_branch = rev_parse_output.strip().lstrip(remote_name + "/")
1107+
remote_branch = rev_parse_output.strip().replace(remote_name + "/", "", 1)
11081108
return {
11091109
"code": code,
11101110
"remote_short_name": remote_name,

jupyterlab_git/tests/test_branch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ async def test_get_current_branch_detached_failure():
408408
("feature-foo", "master", "origin/withslash"),
409409
("master", "master", "origin"),
410410
("feature/bar", "feature-foo", ""),
411+
# Test upstream branch name starts with a letter contained in remote name
412+
("rbranch", "rbranch", "origin"),
411413
],
412414
)
413415
async def test_get_upstream_branch_success(branch, upstream, remotename):

0 commit comments

Comments
 (0)