pkgs/agit: Pre-fill the editor with commit messages

Pre-fill the editor with commit messages for the AGit PR.
This commit is contained in:
a-kenji
2025-06-25 01:51:25 +02:00
parent 67b338918b
commit ef839c1b89

View File

@@ -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")