Class: Dependabot::PullRequestCreator::BranchNamer
- Inherits:
-
Object
- Object
- Dependabot::PullRequestCreator::BranchNamer
- Defined in:
- lib/dependabot/pull_request_creator/branch_namer.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#separator ⇒ Object
readonly
Returns the value of attribute separator.
-
#target_branch ⇒ Object
readonly
Returns the value of attribute target_branch.
Instance Method Summary collapse
-
#initialize(dependencies:, files:, target_branch:, separator: "/", prefix: "dependabot") ⇒ BranchNamer
constructor
A new instance of BranchNamer.
- #new_branch_name ⇒ Object
Constructor Details
#initialize(dependencies:, files:, target_branch:, separator: "/", prefix: "dependabot") ⇒ BranchNamer
Returns a new instance of BranchNamer.
11 12 13 14 15 16 17 18 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 11 def initialize(dependencies:, files:, target_branch:, separator: "/", prefix: "dependabot") @dependencies = dependencies @files = files @target_branch = target_branch @separator = separator @prefix = prefix end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
9 10 11 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 9 def dependencies @dependencies end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
9 10 11 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 9 def files @files end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
9 10 11 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 9 def prefix @prefix end |
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
9 10 11 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 9 def separator @separator end |
#target_branch ⇒ Object (readonly)
Returns the value of attribute target_branch.
9 10 11 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 9 def target_branch @target_branch end |
Instance Method Details
#new_branch_name ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dependabot/pull_request_creator/branch_namer.rb', line 20 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 # Some users need branch names without slashes sanitize_ref(File.join(prefixes, @name).gsub("/", separator)) end |