豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Extract TitleBuilder for PR title composition#14285

Merged
kbukum1 merged 5 commits intomainfrom
kbukum1/refactor-pr-gen-components
Mar 10, 2026
Merged

Extract TitleBuilder for PR title composition#14285
kbukum1 merged 5 commits intomainfrom
kbukum1/refactor-pr-gen-components

Conversation

@kbukum1
Copy link
Copy Markdown
Contributor

@kbukum1 kbukum1 commented Feb 25, 2026

What are you trying to accomplish?

Extract a lightweight TitleBuilder class from MessageBuilder so that PR title composition (prefix + capitalization + base title) can be reused by dependabot-api for multi-ecosystem combined PRs.

The current MessageBuilder inlines prefix/capitalize logic in pr_name, which cannot be called from dependabot-api without instantiating the entire builder. The API currently hardcodes combined PR titles, completely bypassing commit-message prefix configuration.

What changed?

1 new filecommon/lib/dependabot/pull_request_creator/message_builder/title_builder.rb:

  • TitleBuilder#build — composes prefix + capitalization + base title
  • Works with a full PrNamePrefixer (updater path) or lightweight commit_message_options hash (API path, no network calls)
  • TitleBuilder.multi_ecosystem_base_title — class method for generating multi-ecosystem group titles

MessageBuilder#pr_name now delegates to TitleBuilder instead 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 MessageBuilder is minimal (5 lines changed). TitleBuilder follows the same pattern as existing helpers (IssueLinker, MetadataPresenter, LinkAndMentionSanitizer).

How will you know you have accomplished your goal?

  • New TitleBuilder spec passes (10 examples covering prefix, capitalization, scope, dev dependencies, multi-ecosystem)
  • Existing MessageBuilder specs continue to pass (behavior unchanged)
  • dependabot-api companion PR can use TitleBuilder to apply commit-message prefix to combined PRs

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch 4 times, most recently from 7b980a2 to bd3e3b1 Compare March 4, 2026 07:54
@kbukum1 kbukum1 changed the title Refactor: Extract TitleBuilder and strategy components from MessageBuilder Extract TitleBuilder from MessageBuilder for reusable PR title composition Mar 4, 2026
@kbukum1 kbukum1 changed the title Extract TitleBuilder from MessageBuilder for reusable PR title composition Extract TitleBuilder for PR title composition Mar 4, 2026
@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch 2 times, most recently from 9cc56cb to c90bf8f Compare March 4, 2026 19:01
@kbukum1 kbukum1 marked this pull request as ready for review March 4, 2026 19:01
@kbukum1 kbukum1 requested a review from a team as a code owner March 4, 2026 19:01
Copilot AI review requested due to automatic review settings March 4, 2026 19:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TitleBuilder to compose a final PR title from a base title plus either a PrNamePrefixer (updater path) or explicit commit_message_options (API path).
  • Update MessageBuilder#pr_name to delegate title composition to TitleBuilder.
  • 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.

Comment thread common/spec/dependabot/pull_request_creator/message_builder/title_builder_spec.rb Outdated
@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch from c90bf8f to c44f7c3 Compare March 4, 2026 19:21
@kbukum1 kbukum1 requested a review from Copilot March 4, 2026 20:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread common/lib/dependabot/pull_request_creator/message_builder/title_builder.rb Outdated
Comment thread common/lib/dependabot/pull_request_creator/message_builder.rb
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch 2 times, most recently from dea6298 to dd11d12 Compare March 6, 2026 21:36
@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch 2 times, most recently from bf5c99d to d80ad5f Compare March 9, 2026 16:22
@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch from d80ad5f to 4bc2e11 Compare March 9, 2026 20:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@kbukum1 kbukum1 force-pushed the kbukum1/refactor-pr-gen-components branch from 4462117 to 3870174 Compare March 10, 2026 16:55
Copy link
Copy Markdown
Contributor

@AbhishekBhaskar AbhishekBhaskar left a comment

Choose a reason for hiding this comment

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

LGTM

@kbukum1 kbukum1 merged commit 25b65fd into main Mar 10, 2026
314 of 323 checks passed
@kbukum1 kbukum1 deleted the kbukum1/refactor-pr-gen-components branch March 10, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants