Skip to content

Commit

Permalink
chore: modify pr description (#2568)
Browse files Browse the repository at this point in the history
In this PR:
- Wrap commit message with `BEGIN_COMMIT_OVERRIDE` and
`BEGIN_COMMIT_OVERRIDE`.

Context: we found out that the commit messages in
googleapis/google-cloud-java#10529 didn't appear
in the release notes. @chingor13 pointed out that we should wrap commit
messages with `BEGIN_COMMIT_OVERRIDE` and `BEGIN_COMMIT_OVERRIDE` so
that release-please can pick them up from a merged PR.
  • Loading branch information
JoeWang1127 authored Mar 13, 2024
1 parent b2c3f6a commit ff56a20
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
7 changes: 6 additions & 1 deletion library_generation/generate_pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from library_generation.utils.commit_message_formatter import format_commit_message
from library_generation.utilities import get_file_paths
from library_generation.utils.commit_message_formatter import wrap_nested_commit
from library_generation.utils.commit_message_formatter import wrap_override_commit


@click.group(invoke_without_command=False)
Expand Down Expand Up @@ -175,7 +176,11 @@ def __combine_commit_messages(
f"[googleapis/googleapis@{short_sha}](https://github.com/googleapis/googleapis/commit/{commit.hexsha})"
)

messages.extend(format_commit_message(commits=commits, is_monorepo=is_monorepo))
messages.extend(
wrap_override_commit(
format_commit_message(commits=commits, is_monorepo=is_monorepo)
)
)

return "\n".join(messages)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Qualified commits are:
[googleapis/googleapis@0733fdb](https://github.com/googleapis/googleapis/commit/0733fdb5f745192f9f3c95f8d08039286567cbcc)
[googleapis/googleapis@9e35c62](https://github.com/googleapis/googleapis/commit/9e35c620157d7b11cb5b2e5d0249c5caaee824f3)
[googleapis/googleapis@36dedd0](https://github.com/googleapis/googleapis/commit/36dedd0d9020c19d1c8259003c2fe9656ada7471)
BEGIN_COMMIT_OVERRIDE
BEGIN_NESTED_COMMIT
docs: [cloudcontrolspartner] update documentation URL

Expand Down Expand Up @@ -49,4 +50,5 @@ feat: [cloudcontrolspartner] added CloudControlsPartner API

PiperOrigin-RevId: 606720708

END_NESTED_COMMIT
END_NESTED_COMMIT
END_COMMIT_OVERRIDE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ This pull request is generated with proto changes between googleapis commit 6790
Qualified commits are:
[googleapis/googleapis@fbcfef0](https://github.com/googleapis/googleapis/commit/fbcfef09510b842774530989889ed1584a8b5acb)
[googleapis/googleapis@63d2a60](https://github.com/googleapis/googleapis/commit/63d2a60056ad5b156c05c7fb13138fc886c3b739)
BEGIN_COMMIT_OVERRIDE
BEGIN_NESTED_COMMIT
fix: extend timeouts for deleting snapshots, backups and tables

Expand All @@ -13,4 +14,5 @@ chore: update retry settings for backup rpcs

PiperOrigin-RevId: 605367937

END_NESTED_COMMIT
END_NESTED_COMMIT
END_COMMIT_OVERRIDE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from library_generation.utils.commit_message_formatter import format_commit_message
from library_generation.utils.commit_message_formatter import wrap_nested_commit
from library_generation.utils.commit_message_formatter import wrap_override_commit


class CommitMessageFormatterTest(unittest.TestCase):
Expand Down Expand Up @@ -114,3 +115,15 @@ def test_wrap_nested_commit_success(self):
],
wrap_nested_commit(messages),
)

def test_wrap_override_commit_success(self):
messages = ["a commit message", "another message"]
self.assertEqual(
[
"BEGIN_COMMIT_OVERRIDE",
"a commit message",
"another message",
"END_COMMIT_OVERRIDE",
],
wrap_override_commit(messages),
)
13 changes: 13 additions & 0 deletions library_generation/utils/commit_message_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@ def wrap_nested_commit(messages: List[str]) -> List[str]:
result.extend(messages)
result.append("END_NESTED_COMMIT")
return result


def wrap_override_commit(messages: List[str]) -> List[str]:
"""
Wrap message between `BEGIN_COMMIT_OVERRIDE` and `END_COMMIT_OVERRIDE`.
:param messages: a (multi-line) commit message, one line per item.
:return: wrapped messages.
"""
result = ["BEGIN_COMMIT_OVERRIDE"]
result.extend(messages)
result.append("END_COMMIT_OVERRIDE")
return result

0 comments on commit ff56a20

Please sign in to comment.