From d7c32647be3060e44c2c1bcece686373a70f1063 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Sun, 21 Jan 2024 08:44:28 +0000 Subject: [PATCH] Resolve usernames when the remote ends with a trailing slash (#110) --- cherry_picker/cherry_picker.py | 2 +- cherry_picker/test_cherry_picker.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index 66bde15..3e59f39 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -198,7 +198,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(":", "/").rstrip("/").split("/")[-2] return username def get_cherry_pick_branch(self, maint_branch): diff --git a/cherry_picker/test_cherry_picker.py b/cherry_picker/test_cherry_picker.py index bffb11d..3a9f670 100644 --- a/cherry_picker/test_cherry_picker.py +++ b/cherry_picker/test_cherry_picker.py @@ -343,10 +343,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):