Skip to content

Commit d7c3264

Browse files
authored
Resolve usernames when the remote ends with a trailing slash (#110)
1 parent c7a504f commit d7c3264

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

cherry_picker/cherry_picker.py

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

204204
def get_cherry_pick_branch(self, maint_branch):

cherry_picker/test_cherry_picker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,13 @@ def test_get_pr_url(config):
343343
[
344344
b"git@github.com:mock_user/cpython.git",
345345
b"git@github.com:mock_user/cpython",
346+
b"git@github.com:mock_user/cpython/",
346347
b"ssh://git@github.com/mock_user/cpython.git",
347348
b"ssh://git@github.com/mock_user/cpython",
349+
b"ssh://git@github.com/mock_user/cpython/",
348350
b"https://github.com/mock_user/cpython.git",
349351
b"https://github.com/mock_user/cpython",
352+
b"https://github.com/mock_user/cpython/",
350353
],
351354
)
352355
def test_username(url, config):

0 commit comments

Comments
 (0)