diff --git a/scripts/ci/update_pr_body.py b/scripts/ci/update_pr_body.py index caeaa35a17bd..c41b766733fc 100755 --- a/scripts/ci/update_pr_body.py +++ b/scripts/ci/update_pr_body.py @@ -54,15 +54,19 @@ def main() -> None: new_body = pr.body - docs_preview_link_end = new_body.find(DOCS_PREVIEW_MARKER) + len(DOCS_PREVIEW_MARKER) - docs_preview_link_start = new_body.rfind("\n", 0, docs_preview_link_end) + 1 - new_body = new_body[:docs_preview_link_start] + DOCS_PREVIEW_BARE_LINK + new_body[docs_preview_link_end:] - - examples_preview_link_end = new_body.find(EXAMPLES_PREVIEW_MARKER) + len(EXAMPLES_PREVIEW_MARKER) - examples_preview_link_start = new_body.rfind("\n", 0, examples_preview_link_end) + 1 - new_body = ( - new_body[:examples_preview_link_start] + EXAMPLES_PREVIEW_BARE_LINK + new_body[examples_preview_link_end:] - ) + docs_preview_link_end = new_body.find(DOCS_PREVIEW_MARKER) + if docs_preview_link_end != -1: + docs_preview_link_end += len(DOCS_PREVIEW_MARKER) + docs_preview_link_start = new_body.rfind("\n", 0, docs_preview_link_end) + 1 + new_body = new_body[:docs_preview_link_start] + DOCS_PREVIEW_BARE_LINK + new_body[docs_preview_link_end:] + + examples_preview_link_end = new_body.find(EXAMPLES_PREVIEW_MARKER) + if examples_preview_link_end != -1: + len(EXAMPLES_PREVIEW_MARKER) + examples_preview_link_start = new_body.rfind("\n", 0, examples_preview_link_end) + 1 + new_body = ( + new_body[:examples_preview_link_start] + EXAMPLES_PREVIEW_BARE_LINK + new_body[examples_preview_link_end:] + ) new_body = env.from_string(new_body).render( pr={