Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit 1189a45

Browse files
committed
Fix PR template and Reviewable from merge commits
We recently added a PR template to the main Servo repo to smooth the contributing workflow. However, this template gets copied into homu's merge commit messages, generating a lot of noise in the commit logs. Use heuristics to strip both the PR template and the Reviewable footer. First, the main body of the PR template and the Reviewable footer are removed, as these are always the same (except for if the boxes are checked) and always at the bottom. The other part of the PR template is a header comment; some users replace it, while others leave it, and even though the message says to write below that line, some users write above it. So, simply remove it and trim any extra newlines. These heuristics should robustly leave the body untouched if the template is changed. This leaves a much cleaner commit message in the merge commit. Tested against an excerpt of recent commit messages from Servo.
1 parent c62396e commit 1189a45

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

homu/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def create_merge(state, repo_cfg, branch, git_cfg):
450450
state.head_ref,
451451
'<try>' if state.try_ else state.approved_by,
452452
state.title,
453-
state.body,
453+
utils.strip_pr_body(state.body),
454454
)
455455

456456
desc = 'Merge conflict'

homu/utils.py

+13
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,16 @@ def retry_until(inner, fail, state):
9999
traceback.print_exception(*exc_info)
100100

101101
fail(err)
102+
103+
104+
def strip_pr_body(pr_body):
105+
"""
106+
Strip noisy parts of the Servo PR template from merge commits.
107+
"""
108+
# Strip most of the template and Reviewable
109+
pr_footer = '\n---\n<!-- Thank you for contributing to Servo! '
110+
stripped_body = pr_body.partition(pr_footer)[0]
111+
112+
# May or may not exist; may be at the top or bottom of stripped_body
113+
pr_header = '<!-- Please describe your changes on the following line: -->'
114+
return stripped_body.replace(pr_header, '').strip()

0 commit comments

Comments
 (0)