Class: Dependabot::PullRequestCreator::PrNamePrefixer

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/pull_request_creator/pr_name_prefixer.rb

Constant Summary collapse

ANGULAR_PREFIXES =
%w(build chore ci docs feat fix perf refactor style
test).freeze
ESLINT_PREFIXES =
%w(Breaking Build Chore Docs Fix New Update
Upgrade).freeze
GITMOJI_PREFIXES =
%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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of PrNamePrefixer.



31
32
33
34
35
36
37
38
# File 'lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 31

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)


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

def capitalize_first_word?
  if commit_message_options.key?(:prefix)
    return !commit_message_options[:prefix]&.strip&.match?(/\A[a-z]/)
  end

  if last_dependabot_commit_style
    return capitalise_first_word_from_last_dependabot_commit_style
  end

  capitalise_first_word_from_previous_commits
end

#pr_name_prefixObject



40
41
42
43
44
# File 'lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 40

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