From 2732b9ccd2b8babcc30da2a41ae2e3711c0206bc Mon Sep 17 00:00:00 2001 From: Michael Zolotukhin Date: Sun, 16 Nov 2025 14:20:36 -0800 Subject: [PATCH] Don't generate table of contents for stacks with just 1 PR. stack-info: PR: https://github.com/modular/stack-pr/pull/103, branch: ZolotukhinM/stack/1 --- src/stack_pr/cli.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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