diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index f2046ee..423c76f 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -196,7 +196,7 @@ def sorted_branches(self): @property def username(self): cmd = ["git", "config", "--get", f"remote.{self.pr_remote}.url"] - result = self.run_cmd(cmd, required_real_result=True) + result = self.run_cmd(cmd, required_real_result=True).strip() # implicit ssh URIs use : to separate host from user, others just use / username = result.replace(":", "/").rstrip("/").split("/")[-2] return username diff --git a/cherry_picker/test_cherry_picker.py b/cherry_picker/test_cherry_picker.py index 5138c83..9ce5cce 100644 --- a/cherry_picker/test_cherry_picker.py +++ b/cherry_picker/test_cherry_picker.py @@ -351,6 +351,10 @@ def test_get_pr_url(config): b"https://github.com/mock_user/cpython.git", b"https://github.com/mock_user/cpython", b"https://github.com/mock_user/cpython/", + # test trailing whitespace + b"https://github.com/mock_user/cpython.git\n", + b"https://github.com/mock_user/cpython\n", + b"https://github.com/mock_user/cpython/\n", ], ) def test_username(url, config):