Skip to content

Commit 2732b9c

Browse files
committed
Don't generate table of contents for stacks with just 1 PR.
stack-info: PR: #103, branch: ZolotukhinM/stack/1
1 parent a4dc185 commit 2732b9c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/stack_pr/cli.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,10 @@ def create_pr(e: StackEntry, *, is_draft: bool, reviewer: str = "") -> None:
762762

763763

764764
def generate_toc(st: list[StackEntry], current: str) -> str:
765+
# Don't generate TOC for single PR
766+
if len(st) == 1:
767+
return ""
768+
765769
def toc_entry(se: StackEntry) -> str:
766770
pr_id = last(se.pr)
767771
arrow = "__->__" if pr_id == current else ""
@@ -791,10 +795,16 @@ def add_cross_links(st: list[StackEntry], *, keep_body: bool, verbose: bool) ->
791795

792796
# Strip stack-info from the body, nothing interesting there.
793797
body = RE_STACK_INFO_LINE.sub("", body)
794-
pr_body = [
795-
f"{pr_toc}",
796-
f"{CROSS_LINKS_DELIMETER}\n",
797-
]
798+
pr_body = []
799+
800+
# Only add TOC and delimiter if there are multiple PRs in the stack
801+
if pr_toc:
802+
pr_body.extend(
803+
[
804+
f"{pr_toc}",
805+
f"{CROSS_LINKS_DELIMETER}\n",
806+
]
807+
)
798808

799809
if keep_body:
800810
# Keep current body of the PR after the cross links component

0 commit comments

Comments
 (0)