Skip to content

Commit 463a60d

Browse files
committed
fix ssh urls to https
1 parent 78132fa commit 463a60d

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.8.4
2+
3+
### Prs in Release
4+
5+
- [Fix SSH urls to HTTPS]()
6+
17
## 0.8.3
28

39
### Prs in Release

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@ Once you're done configuring, run either `mkdocs serve` or `mkdocs build`. This
174174

175175
## Additional Features
176176

177+
### Support ssh urls for import
178+
179+
If an imported repo is imported via an ssh connection, the edit url needs to be modified to reflect an https link.
180+
181+
```
182+
plugins:
183+
- search
184+
- awesome-pages
185+
- multirepo:
186+
cleanup: false
187+
repos:
188+
- section: Some MKDocs Repo
189+
section_path: mkdocs
190+
import_url: 'ssh://[email protected]/mkdocs/some-repo?branch=main&edit_uri=blob/main/docs'
191+
```
192+
193+
This url is modified to remove the `ssh://git@` or `git@` with `https://` creating the correct edit url.
194+
177195
### α Multiple Docs Directories in Imported Repo (Alpha)
178196
179197
If an imported repo is a monorepo (i.e., has multiple *docs* directories), *multirepo* automatically includes them in the site when `multi_docs` is set to `True`.

mkdocs_multirepo_plugin/structure.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ def keep_docs_dir(self, global_keep_docs_dir: bool = False):
308308
if self._keep_docs_dir is None:
309309
return global_keep_docs_dir
310310
return self._keep_docs_dir
311+
312+
def get_https_url(self, source_url: str) -> str:
313+
"""Converts a git url to an https url"""
314+
if source_url.startswith("ssh://"):
315+
source_url = source_url.replace("ssh://", "")
316+
if source_url.startswith("git@"):
317+
source_url = source_url.replace(":", "/").replace("git@", "https://")
318+
return source_url
311319

312320
def get_edit_url(
313321
self, src_path, keep_docs_dir: bool = False, nav_repos: bool = False
@@ -319,14 +327,14 @@ def get_edit_url(
319327
if parent_path in self.src_path_map:
320328
src_path = Path(src_path)
321329
url_parts = [
322-
self.url,
330+
self.get_https_url(self.url),
323331
self.edit_uri,
324332
self.src_path_map.get(parent_path),
325333
str(src_path.name),
326334
]
327335
else:
328336
url_parts = [
329-
self.url,
337+
self.get_https_url(self.url),
330338
self.edit_uri,
331339
self.src_path_map.get(str(src_path), str(src_path)),
332340
]
@@ -335,10 +343,10 @@ def get_edit_url(
335343
or self.keep_docs_dir(global_keep_docs_dir=keep_docs_dir)
336344
or nav_repos
337345
):
338-
url_parts = [self.url, self.edit_uri, src_path]
346+
url_parts = [self.get_https_url(self.url), self.edit_uri, src_path]
339347
else:
340348
url_parts = [
341-
self.url,
349+
self.get_https_url(self.url),
342350
self.edit_uri,
343351
self.docs_dir.replace("/*", ""),
344352
src_path,

0 commit comments

Comments
 (0)