From 26c63f44000163b71d7baa93780478aa4cd28bb2 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Thu, 5 Sep 2024 19:26:03 +0300 Subject: [PATCH] scripts/merge-pr.py: Wrap merge commit message to 72 columns --- scripts/merge-pr.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/merge-pr.py b/scripts/merge-pr.py index 80ea7e68..db224f5e 100755 --- a/scripts/merge-pr.py +++ b/scripts/merge-pr.py @@ -15,6 +15,7 @@ import os import subprocess import tempfile +import textwrap def run_command(command): @@ -68,6 +69,10 @@ def get_pr_info(g, repo, pr_number): } +def wrap_text(text, width=72): + return '\n'.join(textwrap.wrap(text, width=width)) + + def merge_pr(pr_number): # GitHub authentication token = os.getenv('GITHUB_TOKEN') @@ -84,7 +89,10 @@ def merge_pr(pr_number): pr_info = get_pr_info(g, repo, pr_number) # Format commit message - commit_message = f"Merge '{pr_info['title']}' from {pr_info['author']}\n\n{pr_info['body']}\n" + commit_title = f"Merge '{pr_info['title']}' from {pr_info['author']}" + commit_body = wrap_text(pr_info['body']) + + commit_message = f"{commit_title}\n\n{commit_body}\n" # Add Reviewed-by lines for approver in pr_info['reviewed_by']: