From 7dc11c03912b5c48a0cda02a9a83e56b110dcbd8 Mon Sep 17 00:00:00 2001 From: Bortlesboat <169967362+Bortlesboat@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:58:05 -0400 Subject: [PATCH] Print the top of the stack first in submit output diffs_to_submit has been top-first since the head/base rewrite, so the reversed() calls now print the bottom PR first. That contradicts the --short comment and makes the summary list the stack upside down. Fixes #239 --- src/ghstack/submit.py | 4 ++-- test/submit/short_stack.py.test | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/submit/short_stack.py.test diff --git a/src/ghstack/submit.py b/src/ghstack/submit.py index 6c52ff0..a01cf1f 100644 --- a/src/ghstack/submit.py +++ b/src/ghstack/submit.py @@ -2164,14 +2164,14 @@ def format_url(s: DiffMeta) -> str: if self.short: # Guarantee that the FIRST PR URL is the top of the stack - print("\n".join(format_url(s) for s in reversed(diffs_to_submit))) + print("\n".join(format_url(s) for s in diffs_to_submit)) return print() print("# Summary of changes (ghstack {})".format(ghstack.__version__)) print() if diffs_to_submit: - for s in reversed(diffs_to_submit): + for s in diffs_to_submit: url = format_url(s) print(" - {} {}".format(s.what, url)) diff --git a/test/submit/short_stack.py.test b/test/submit/short_stack.py.test new file mode 100644 index 0000000..eebedf9 --- /dev/null +++ b/test/submit/short_stack.py.test @@ -0,0 +1,15 @@ +from ghstack.test_prelude import * + +await init_test() + +await commit("A") +await commit("B") +with captured_output() as (out, err): + await gh_submit("Initial", short=True) +assert_eq( + out.getvalue(), + "https://github.com/pytorch/pytorch/pull/501\n" + "https://github.com/pytorch/pytorch/pull/500\n", +) + +ok()