Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add NESTED_COMMIT markers when combining multiple source commits #4426

Merged
merged 11 commits into from
Sep 27, 2022

Conversation

chingor13
Copy link
Contributor

@chingor13 chingor13 commented Sep 19, 2022

In googleapis/release-please#1566, we added the ability to explicitly denote multiple commit messages by using BEGIN_NESTED_COMMIT/END_NESTED_COMMIT markers.

This PR now augments owl-bot to include those markers when combining multiple copy-code runs in a single PR. We add a new prependCommitMessage helper that encapsulates the logic of recombining a previous owl-bot copy PR, wrapping the previous message in a BEGIN/END_NESTED_COMMIT block and pre-pending the new commit message.

Note that any existing PR bodies will be grouped together into a single nested commit when the next copy code commit is added.

Fixes #3342

@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Sep 19, 2022
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xs Pull request size is extra small. labels Sep 19, 2022
@chingor13 chingor13 marked this pull request as ready for review September 19, 2022 20:20
@chingor13 chingor13 requested a review from a team September 19, 2022 20:20
@chingor13 chingor13 changed the title test: failing test for adding BEGIN/END_NESTED_COMMIT markers @chingor13 feat: add NESTED_COMMIT markers when combining multiple source commits Sep 19, 2022
@chingor13 chingor13 changed the title @chingor13 feat: add NESTED_COMMIT markers when combining multiple source commits feat: add NESTED_COMMIT markers when combining multiple source commits Sep 19, 2022
@chingor13
Copy link
Contributor Author

chingor13 commented Sep 19, 2022

Do not merge until after #4427 is deployed

Copy link
Contributor

@SurferJeffAtGoogle SurferJeffAtGoogle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a flag to enable this new behavior.

Do the delimiters get added when a PR contains only a single commit?

packages/owl-bot/__snapshots__/create-pr.js Outdated Show resolved Hide resolved
packages/owl-bot/src/create-pr.ts Outdated Show resolved Hide resolved
.join(NESTED_COMMIT_SEPARATOR)}`;

// prepend the new commit message and use original title truncation logic
return resplit(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call prependCommitMessage before calling resplit? Then resplit gets called only once and the unsplitting logic in this function can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title/first line splitting deals with the PR title limitation of 256 characters. If the previous commit was >256 characters, then the message uses the ellipses to split the message. We do want to rejoin that previous message to be nicer for the release notes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do want to rejoin that previous message to be nicer for the release notes.

Indeed, so why not call this function on the original message (before resplit)?

packages/owl-bot/test/create-pr.ts Outdated Show resolved Hide resolved
@chingor13
Copy link
Contributor Author

@SurferJeffAtGoogle I'm unsure how we want to opt-in this functionality. In code, I added an enum that is surfaced as a CLI argument, but I'm unsure how we want to configure an opt-in for a repository.

@SurferJeffAtGoogle
Copy link
Contributor

I'm unsure how we want to opt-in this functionality. In code, I added an enum that is surfaced as a CLI argument, but I'm unsure how we want to configure an opt-in for a repository.

The CLI argument looks great!

@SurferJeffAtGoogle
Copy link
Contributor

Do the delimiters get added when a PR contains only a single commit?

@chingor13
Copy link
Contributor Author

Do the delimiters get added when a PR contains only a single commit?

No, they are only added when we append to an existing PR

WithRegenerateCheckbox.Yes
const {title, body} = prependCommitMessage(
commitBody,
{title: pull.title, body: pull.body || ''},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the typescript idiom is pull.body ?? ''.

@chingor13
Copy link
Contributor Author

/gcbrun

@chingor13 chingor13 enabled auto-merge (squash) September 26, 2022 23:24
@chingor13
Copy link
Contributor Author

/gcbrun

2 similar comments
@chingor13
Copy link
Contributor Author

/gcbrun

@chingor13
Copy link
Contributor Author

/gcbrun

@chingor13 chingor13 merged commit f4be398 into main Sep 27, 2022
@chingor13 chingor13 deleted the owlbot-multi-commit-messages branch September 27, 2022 21:26
@meltsufin
Copy link
Member

@SurferJeffAtGoogle @chingor13 This still doesn't seem to be working on the Java monorepo. Do we need to add any config?
Example: googleapis/google-cloud-java#8614

@release-please release-please bot mentioned this pull request Aug 21, 2023
@release-please release-please bot mentioned this pull request Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Owlbot multiple commit descriptions can miss release notes
3 participants