Skip to content

File tree

1 file changed

+6
-1
lines changed
  • readthedocs/vcs_support/backends

1 file changed

+6
-1
lines changed

readthedocs/vcs_support/backends/git.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ def has_ssh_key_with_write_access(self) -> bool:
174174
to ensure that no commands controled by the user are run.
175175
"""
176176
remote_name = "rtd-test-ssh-key"
177-
ssh_url = re.sub("https?://github.com/", "[email protected]:", self.project.repo, 1)
177+
ssh_url = self.project.repo
178+
if ssh_url.startswith("http"):
179+
parsed_url = urlparse(ssh_url)
180+
ssh_url = f"git@{parsed_url.netloc}:{parsed_url.path.lstrip('/')}"
178181

179182
try:
180183
cmd = ["git", "remote", "add", remote_name, ssh_url]
@@ -215,6 +218,8 @@ def has_ssh_key_with_write_access(self) -> bool:
215218
# but since the key can't be used from the builders,
216219
# it should be safe to return False.
217220
"ERROR: The repository owner has an IP allow list enabled",
221+
# Gitlab:
222+
"ERROR: This deploy key does not have write access to this project.",
218223
]
219224
for pattern in errors_read_access_only:
220225
if pattern in stderr:

0 commit comments

Comments
 (0)