From ef839c1b89ec87992996f89a83baf0ea84083d20 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Wed, 25 Jun 2025 01:51:25 +0200 Subject: [PATCH] pkgs/agit: Pre-fill the editor with commit messages Pre-fill the editor with commit messages for the AGit PR. --- pkgs/agit/agit.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/agit/agit.py b/pkgs/agit/agit.py index 23318ada2..d6820668a 100644 --- a/pkgs/agit/agit.py +++ b/pkgs/agit/agit.py @@ -253,6 +253,15 @@ def open_editor_for_pr() -> tuple[str, str]: with tempfile.NamedTemporaryFile( mode="w+", suffix="COMMIT_EDITMSG", delete=False ) as temp_file: + temp_file.flush() + temp_file_path = temp_file.name + + for title, body in commits_since_main: + temp_file.write(f"{title}\n") + if body: + temp_file.write(f"{body}\n") + temp_file.write("\n") + temp_file.write("\n") temp_file.write("# Please enter the PR title on the first line.\n") temp_file.write("# Lines starting with '#' will be ignored.\n") @@ -272,8 +281,6 @@ def open_editor_for_pr() -> tuple[str, str]: for line in body.split("\n"): temp_file.write(f"# {line}\n") temp_file.write("#\n") - temp_file.flush() - temp_file_path = temp_file.name try: editor = os.environ.get("EDITOR", "vim")