diff --git a/src/stack_pr/cli.py b/src/stack_pr/cli.py index a9f00e5..95791e9 100755 --- a/src/stack_pr/cli.py +++ b/src/stack_pr/cli.py @@ -762,6 +762,10 @@ def create_pr(e: StackEntry, *, is_draft: bool, reviewer: str = "") -> None: def generate_toc(st: list[StackEntry], current: str) -> str: + # Don't generate TOC for single PR + if len(st) == 1: + return "" + def toc_entry(se: StackEntry) -> str: pr_id = last(se.pr) arrow = "__->__" if pr_id == current else "" @@ -791,10 +795,16 @@ def add_cross_links(st: list[StackEntry], *, keep_body: bool, verbose: bool) -> # Strip stack-info from the body, nothing interesting there. body = RE_STACK_INFO_LINE.sub("", body) - pr_body = [ - f"{pr_toc}", - f"{CROSS_LINKS_DELIMETER}\n", - ] + pr_body = [] + + # Only add TOC and delimiter if there are multiple PRs in the stack + if pr_toc: + pr_body.extend( + [ + f"{pr_toc}", + f"{CROSS_LINKS_DELIMETER}\n", + ] + ) if keep_body: # Keep current body of the PR after the cross links component