8000 Handle whitespace when calculating usernames (#132) · python/cherry-picker@bea8856 · GitHub
[go: up one dir, main page]

Skip to content

Commit bea8856

Browse files
authored
Handle whitespace when calculating usernames (#132)
1 parent 68153a8 commit bea8856

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cherry_picker/cherry_picker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def sorted_branches(self):
196196
@property
197197
def username(self):
198198
cmd = ["git", "config", "--get", f"remote.{self.pr_remote}.url"]
199-
result = self.run_cmd(cmd, required_real_result=True)
199+
result = self.run_cmd(cmd, required_real_result=True).strip()
200200
# implicit ssh URIs use : to separate host from user, others just use /
201201
username = result.replace(":", "/").rstrip("/").split("/")[-2]
202202
return username

cherry_picker/test_cherry_picker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ def test_get_pr_url(config):
351351
b"https://github.com/mock_user/cpython.git",
352352
b"https://github.com/mock_user/cpython",
353353
b"https://github.com/mock_user/cpython/",
354+
# test trailing whitespace
355+
b"https://github.com/mock_user/cpython.git\n",
356+
b"https://github.com/mock_user/cpython\n",
357+
b"https://github.com/mock_user/cpython/\n",
354358
],
355359
)
356360
def test_username(url, config):

0 commit comments

Comments
 (0)
0