Skip to content

Commit

Permalink
scripts/merge-pr.py: Wrap merge commit message to 72 columns
Browse files Browse the repository at this point in the history
  • Loading branch information
penberg committed Sep 5, 2024
1 parent d8855e2 commit 26c63f4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/merge-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import subprocess
import tempfile
import textwrap


def run_command(command):
Expand Down Expand Up @@ -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')
Expand All @@ -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']:
Expand Down

0 comments on commit 26c63f4

Please sign in to comment.