mirror of https://github.com/tiangolo/fastapi.git
🔨 Refactor script `deploy_docs_status.py` to account for deploy URLs with or without trailing slash (#11965)
This commit is contained in:
parent
0eddc02aca
commit
58279670b6
|
|
@ -49,6 +49,7 @@ def main():
|
||||||
files = list(use_pr.get_files())
|
files = list(use_pr.get_files())
|
||||||
docs_files = [f for f in files if f.filename.startswith("docs/")]
|
docs_files = [f for f in files if f.filename.startswith("docs/")]
|
||||||
|
|
||||||
|
deploy_url = settings.deploy_url.rstrip("/")
|
||||||
lang_links: dict[str, list[str]] = {}
|
lang_links: dict[str, list[str]] = {}
|
||||||
for f in docs_files:
|
for f in docs_files:
|
||||||
match = re.match(r"docs/([^/]+)/docs/(.*)", f.filename)
|
match = re.match(r"docs/([^/]+)/docs/(.*)", f.filename)
|
||||||
|
|
@ -60,9 +61,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
path = path.replace(".md", "/")
|
path = path.replace(".md", "/")
|
||||||
if lang == "en":
|
if lang == "en":
|
||||||
link = f"{settings.deploy_url}{path}"
|
link = f"{deploy_url}/{path}"
|
||||||
else:
|
else:
|
||||||
link = f"{settings.deploy_url}{lang}/{path}"
|
link = f"{deploy_url}/{lang}/{path}"
|
||||||
lang_links.setdefault(lang, []).append(link)
|
lang_links.setdefault(lang, []).append(link)
|
||||||
|
|
||||||
links: list[str] = []
|
links: list[str] = []
|
||||||
|
|
@ -79,9 +80,7 @@ def main():
|
||||||
current_lang_links.sort()
|
current_lang_links.sort()
|
||||||
links.extend(current_lang_links)
|
links.extend(current_lang_links)
|
||||||
|
|
||||||
message = (
|
message = f"📝 Docs preview for commit {settings.commit_sha} at: {deploy_url}"
|
||||||
f"📝 Docs preview for commit {settings.commit_sha} at: {settings.deploy_url}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if links:
|
if links:
|
||||||
message += "\n\n### Modified Pages\n\n"
|
message += "\n\n### Modified Pages\n\n"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue