Extract TitleBuilder for PR title composition#14285
Conversation
7b980a2 to
bd3e3b1
Compare
9cc56cb to
c90bf8f
Compare
There was a problem hiding this comment.
Pull request overview
This PR extracts PR title composition logic out of MessageBuilder into a new TitleBuilder helper so title prefixing/capitalization can be reused (notably by dependabot-api for multi-ecosystem combined PRs) while keeping MessageBuilder#pr_name behavior consistent.
Changes:
- Add
TitleBuilderto compose a final PR title from a base title plus either aPrNamePrefixer(updater path) or explicitcommit_message_options(API path). - Update
MessageBuilder#pr_nameto delegate title composition toTitleBuilder. - Add specs covering prefix, scope, dev prefix behavior, and multi-ecosystem base title generation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| common/lib/dependabot/pull_request_creator/message_builder/title_builder.rb | Introduces extracted title composition logic intended for reuse outside MessageBuilder. |
| common/lib/dependabot/pull_request_creator/message_builder.rb | Delegates pr_name formatting to TitleBuilder and requires the new helper. |
| common/spec/dependabot/pull_request_creator/message_builder/title_builder_spec.rb | Adds unit tests for the new TitleBuilder behavior. |
You can also share your feedback on Copilot code review. Take the survey.
c90bf8f to
c44f7c3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
dea6298 to
dd11d12
Compare
bf5c99d to
d80ad5f
Compare
d80ad5f to
4bc2e11
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
4462117 to
3870174
Compare
What are you trying to accomplish?
Extract a lightweight
TitleBuilderclass fromMessageBuilderso that PR title composition (prefix + capitalization + base title) can be reused bydependabot-apifor multi-ecosystem combined PRs.The current
MessageBuilderinlines prefix/capitalize logic inpr_name, which cannot be called fromdependabot-apiwithout instantiating the entire builder. The API currently hardcodes combined PR titles, completely bypassingcommit-messageprefix configuration.What changed?
1 new file —
common/lib/dependabot/pull_request_creator/message_builder/title_builder.rb:TitleBuilder#build— composes prefix + capitalization + base titlePrNamePrefixer(updater path) or lightweightcommit_message_optionshash (API path, no network calls)TitleBuilder.multi_ecosystem_base_title— class method for generating multi-ecosystem group titlesMessageBuilder#pr_namenow delegates toTitleBuilderinstead of inlining the prefix/capitalize logic. No feature flag — the change is a pure extraction with identical behavior.Anything you want to highlight for special attention from reviewers?
The change to
MessageBuilderis minimal (5 lines changed).TitleBuilderfollows the same pattern as existing helpers (IssueLinker,MetadataPresenter,LinkAndMentionSanitizer).How will you know you have accomplished your goal?
TitleBuilderspec passes (10 examples covering prefix, capitalization, scope, dev dependencies, multi-ecosystem)MessageBuilderspecs continue to pass (behavior unchanged)dependabot-apicompanion PR can useTitleBuilderto applycommit-messageprefix to combined PRsChecklist