Class: Dependabot::PullRequestCreator::MessageBuilder::TitleBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/pull_request_creator/message_builder/title_builder.rb

Overview

Composes a final PR title from a base title + prefix.

Works in two modes:

  1. With a full PrNamePrefixer (updater path — has source/credentials for commit style auto-detection)
  2. With just commit_message_options (API path — explicit prefix only, no network calls needed)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_title:, prefixer: nil, commit_message_options: nil, dependencies: nil) ⇒ TitleBuilder

Returns a new instance of TitleBuilder.



43
44
45
46
47
48
49
50
51
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 43

def initialize(base_title:, prefixer: nil, commit_message_options: nil, dependencies: nil)
  @base_title = base_title
  @prefixer = prefixer
  @commit_message_options = T.let(
    commit_message_options && CommitMessageOptions.from_hash(commit_message_options),
    T.nilable(CommitMessageOptions)
  )
  @dependencies = dependencies
end

Instance Attribute Details

#base_titleObject (readonly)

Returns the value of attribute base_title.



24
25
26
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 24

def base_title
  @base_title
end

#commit_message_optionsObject (readonly)

Returns the value of attribute commit_message_options.



30
31
32
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 30

def commit_message_options
  @commit_message_options
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



33
34
35
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 33

def dependencies
  @dependencies
end

#prefixerObject (readonly)

Returns the value of attribute prefixer.



27
28
29
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 27

def prefixer
  @prefixer
end

Class Method Details

.multi_ecosystem_base_title(group_name:, update_count:) ⇒ Object



55
56
57
58
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 55

def self.multi_ecosystem_base_title(group_name:, update_count:)
  "bump the \"#{group_name}\" group with " \
    "#{update_count} update#{'s' unless update_count == 1} across multiple ecosystems"
end

Instance Method Details

#buildObject



61
62
63
64
65
# File 'lib/dependabot/pull_request_creator/message_builder/title_builder.rb', line 61

def build
  name = base_title.dup
  name[0] = T.must(name[0]).capitalize if !name.empty? && capitalize?
  "#{prefix}#{name}"
end