Class: Dependabot::PullRequestCreator::PrNamePrefixer

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

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

ANGULAR_PREFIXES =
T.let(
  %w(build chore ci docs feat fix perf refactor style test).freeze,
  T::Array[String]
)
ESLINT_PREFIXES =
T.let(
  %w(Breaking Build Chore Docs Fix New Update Upgrade).freeze,
  T::Array[String]
)
GITMOJI_PREFIXES =
T.let(
  %w(alien ambulance apple arrow_down arrow_up art beers bento bookmark boom bug building_construction bulb
     busts_in_silhouette camera_flash card_file_box chart_with_upwards_trend checkered_flag children_crossing
     clown_face construction construction_worker egg fire globe_with_meridians green_apple green_heart hankey
     heavy_minus_sign heavy_plus_sign iphone lipstick lock loud_sound memo mute ok_hand package page_facing_up
     pencil2 penguin pushpin recycle rewind robot rocket rotating_light see_no_evil sparkles speech_balloon tada
     truck twisted_rightwards_arrows whale wheelchair white_check_mark wrench zap).freeze,
  T::Array[String]
)

Instance Method Summary collapse

Constructor Details

#initialize(source:, dependencies:, credentials:, security_fix: false, commit_message_options: {}) ⇒ PrNamePrefixer

Returns a new instance of PrNamePrefixer.



46
47
48
49
50
51
52
53
# File 'lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 46

def initialize(source:, dependencies:, credentials:, security_fix: false,
               commit_message_options: {})
  @dependencies           = dependencies
  @source                 = source
  @credentials            = credentials
  @security_fix           = security_fix
  @commit_message_options = commit_message_options
end

Instance Method Details

#capitalize_first_word?Boolean

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
# File 'lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 63

def capitalize_first_word?
  return capitalise_first_word_from_last_dependabot_commit_style if last_dependabot_commit_style

  capitalise_first_word_from_previous_commits
rescue StandardError
  # ignoring failure due to network call to find out if the PR should be capitalized
  false
end

#pr_name_prefixObject



56
57
58
59
60
# File 'lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 56

def pr_name_prefix
  prefix = commit_prefix.to_s
  prefix += security_prefix if security_fix?
  prefix.gsub("⬆️ 🔒", "⬆️🔒")
end