Skip to content

Commit

Permalink
Bug Fix: Replace lstrip with replace function (#849)
Browse files Browse the repository at this point in the history
* Replace lstrip with replace function

* replace only first occurrence of remote

* add unit test

* make formatter happy
  • Loading branch information
rrao24 authored Dec 23, 2020
1 parent e3cae9e commit 80f359f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jupyterlab_git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ async def get_upstream_branch(self, current_path, branch_name):
return {"code": code, "command": " ".join(command), "message": error}

remote_name = output.strip()
remote_branch = rev_parse_output.strip().lstrip(remote_name + "/")
remote_branch = rev_parse_output.strip().replace(remote_name + "/", "", 1)
return {
"code": code,
"remote_short_name": remote_name,
Expand Down
2 changes: 2 additions & 0 deletions jupyterlab_git/tests/test_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ async def test_get_current_branch_detached_failure():
("feature-foo", "master", "origin/withslash"),
("master", "master", "origin"),
("feature/bar", "feature-foo", ""),
# Test upstream branch name starts with a letter contained in remote name
("rbranch", "rbranch", "origin"),
],
)
async def test_get_upstream_branch_success(branch, upstream, remotename):
Expand Down

0 comments on commit 80f359f

Please sign in to comment.