From 128c974e3a1cf1480607d04bb39d87ef0c65d51a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 20 Jan 2024 12:25:08 +0000 Subject: [PATCH 1/3] Resolve usernames when the remote ends with a trailing slash --- cherry_picker/cherry_picker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index c3c6e60..bd6239d 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -196,7 +196,7 @@ def username(self): cmd = ["git", "config", "--get", f"remote.{self.pr_remote}.url"] result = self.run_cmd(cmd, required_real_result=True) # implicit ssh URIs use : to separate host from user, others just use / - username = result.replace(":", "/").split("/")[-2] + username = result.replace(":", "/").removesuffix("/").split("/")[-2] return username def get_cherry_pick_branch(self, maint_branch): From a9ddbcdc49569f513c21073d244aec4e7eaf0b1f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sat, 20 Jan 2024 15:28:40 +0000 Subject: [PATCH 2/3] 3.8 support --- cherry_picker/cherry_picker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index bd6239d..96126fc 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -196,7 +196,7 @@ def username(self): cmd = ["git", "config", "--get", f"remote.{self.pr_remote}.url"] result = self.run_cmd(cmd, required_real_result=True) # implicit ssh URIs use : to separate host from user, others just use / - username = result.replace(":", "/").removesuffix("/").split("/")[-2] + username = result.replace(":", "/").rstrip("/").split("/")[-2] return username def get_cherry_pick_branch(self, maint_branch): From 6eeae09aa15aee65e5e0702ad3708d0e25902f0d Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 21 Jan 2024 08:38:21 +0000 Subject: [PATCH 3/3] Tests --- cherry_picker/test_cherry_picker.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cherry_picker/test_cherry_picker.py b/cherry_picker/test_cherry_picker.py index d99ea81..e12b68e 100644 --- a/cherry_picker/test_cherry_picker.py +++ b/cherry_picker/test_cherry_picker.py @@ -335,10 +335,13 @@ def test_get_pr_url(config): [ b"git@github.com:mock_user/cpython.git", b"git@github.com:mock_user/cpython", + b"git@github.com:mock_user/cpython/", b"ssh://git@github.com/mock_user/cpython.git", b"ssh://git@github.com/mock_user/cpython", + b"ssh://git@github.com/mock_user/cpython/", b"https://github.com/mock_user/cpython.git", b"https://github.com/mock_user/cpython", + b"https://github.com/mock_user/cpython/", ], ) def test_username(url, config):