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

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

Instance Attribute Summary

Attributes inherited from Base

#dependencies, #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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dependabot/pull_request_creator/branch_namer/solo_strategy.rb', line 13

def new_branch_name
  @name ||=
    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

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