Merge pull request 'pkgs/agit: Pre-fill the editor with commit messages' (#4083) from kenji/pkgs/agit: Pre-fill the editor with commit messages into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4083
This commit is contained in:
kenji
2025-06-25 10:52:22 +00:00

View File

@@ -265,6 +265,15 @@ def open_editor_for_pr() -> tuple[str, str]:
with tempfile.NamedTemporaryFile( with tempfile.NamedTemporaryFile(
mode="w+", suffix="COMMIT_EDITMSG", delete=False mode="w+", suffix="COMMIT_EDITMSG", delete=False
) as temp_file: ) 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("\n")
temp_file.write("# Please enter the PR title on the first line.\n") temp_file.write("# Please enter the PR title on the first line.\n")
temp_file.write("# Lines starting with '#' will be ignored.\n") temp_file.write("# Lines starting with '#' will be ignored.\n")
@@ -284,8 +293,6 @@ def open_editor_for_pr() -> tuple[str, str]:
for line in body.split("\n"): for line in body.split("\n"):
temp_file.write(f"# {line}\n") temp_file.write(f"# {line}\n")
temp_file.write("#\n") temp_file.write("#\n")
temp_file.flush()
temp_file_path = temp_file.name
try: try:
editor = os.environ.get("EDITOR", "vim") editor = os.environ.get("EDITOR", "vim")