Class: Dependabot::PullRequestCreator::BranchNamer::SoloStrategy

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/pull_request_creator/branch_namer/solo_strategy.rb

Instance Attribute Summary

Attributes inherited from Base

#dependencies, #existing_branches, #files, #max_length, #prefix, #separator, #target_branch

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dependabot::PullRequestCreator::BranchNamer::Base

Instance Method Details

#new_branch_nameObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dependabot/pull_request_creator/branch_namer/solo_strategy.rb', line 17

def new_branch_name
  return short_branch_name if branch_name_might_be_long?

  @name ||=
    T.let(
      begin
        dependency_name_part =
          if dependencies.count > 1 && updating_a_property?
            property_name
          elsif dependencies.count > 1 && updating_a_dependency_set?
            dependency_set.fetch(:group)
          else
            dependencies
              .map(&:name)
              .join("-and-")
              .tr(":[]", "-")
              .tr("@", "")
          end

        "#{dependency_name_part}-#{branch_version_suffix}"
      end,
      T.nilable(String)
    )

  sanitize_branch_name(File.join(prefixes, @name))
end