diff --git a/dev/merge_arrow_pr.py b/dev/merge_arrow_pr.py index 54729c0a52c..352befc3289 100755 --- a/dev/merge_arrow_pr.py +++ b/dev/merge_arrow_pr.py @@ -575,10 +575,10 @@ def extract_co_authors(commit): commit_title = f'{self.title} (#{self.number})' commit_message_chunks = [] if self.body is not None: - # Remove comments (i.e. <-- comment -->) from the pull request description. - body = re.sub(r"", "", self.body) + # Remove comments (i.e. <-- comment -->) from the PR description. + body = re.sub(r"", "", self.body, flags=re.DOTALL) # avoid github user name references by inserting a space after @ - body = re.sub(r"@(\w+)", "@ \\1", self.body) + body = re.sub(r"@(\w+)", "@ \\1", body) commit_message_chunks.append(body) committer_name = run_cmd("git config --get user.name").strip() @@ -596,9 +596,16 @@ def extract_co_authors(commit): commit_message = "\n\n".join(commit_message_chunks) + # Normalize line ends and collapse extraneous newlines. We allow two + # consecutive newlines for paragraph breaks but not more. + commit_message = "\n".join(commit_message.splitlines()) + commit_message = re.sub("\n{2,}", "\n\n", commit_message) + if DEBUG: + print("*** Commit title ***") print(commit_title) print() + print("*** Commit message ***") print(commit_message) if DEBUG: