Class: Dependabot::PullRequestCreator::MessageBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/pull_request_creator/message_builder.rb,
lib/dependabot/pull_request_creator/message_builder/issue_linker.rb,
lib/dependabot/pull_request_creator/message_builder/metadata_presenter.rb,
lib/dependabot/pull_request_creator/message_builder/link_and_mention_sanitizer.rb

Overview

MessageBuilder builds PR message for a dependency update

Defined Under Namespace

Classes: IssueLinker, LinkAndMentionSanitizer, MetadataPresenter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, commit_message_options: {}, vulnerabilities_fixed: {}, github_redirection_service:) ⇒ MessageBuilder

Returns a new instance of MessageBuilder.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 25

def initialize(source:, dependencies:, files:, credentials:,
               pr_message_header: nil, pr_message_footer: nil,
               commit_message_options: {}, vulnerabilities_fixed: {},
               github_redirection_service:)
  @dependencies               = dependencies
  @files                      = files
  @source                     = source
  @credentials                = credentials
  @pr_message_header          = pr_message_header
  @pr_message_footer          = pr_message_footer
  @commit_message_options     = commit_message_options
  @vulnerabilities_fixed      = vulnerabilities_fixed
  @github_redirection_service = github_redirection_service
end

Instance Attribute Details

#commit_message_optionsObject (readonly)

Returns the value of attribute commit_message_options.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def commit_message_options
  @commit_message_options
end

#credentialsObject (readonly)

Returns the value of attribute credentials.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def credentials
  @credentials
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def dependencies
  @dependencies
end

#filesObject (readonly)

Returns the value of attribute files.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def files
  @files
end

#github_redirection_serviceObject (readonly)

Returns the value of attribute github_redirection_service.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def github_redirection_service
  @github_redirection_service
end

Returns the value of attribute pr_message_footer.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def pr_message_footer
  @pr_message_footer
end

#pr_message_headerObject (readonly)

Returns the value of attribute pr_message_header.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def pr_message_header
  @pr_message_header
end

#sourceObject (readonly)

Returns the value of attribute source.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def source
  @source
end

#vulnerabilities_fixedObject (readonly)

Returns the value of attribute vulnerabilities_fixed.


20
21
22
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 20

def vulnerabilities_fixed
  @vulnerabilities_fixed
end

Instance Method Details

#commit_messageObject


53
54
55
56
57
58
59
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 53

def commit_message
  message = commit_subject + "\n\n"
  message += commit_message_intro
  message += 
  message += "\n\n" + message_trailers if message_trailers
  message
end

#messageObject


61
62
63
64
65
66
67
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 61

def message
  Dependabot::PullRequestCreator::Message.new(
    pr_name: pr_name,
    pr_message: pr_message,
    commit_message: commit_message
  )
end

#pr_messageObject


48
49
50
51
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 48

def pr_message
  suffixed_pr_message_header + commit_message_intro + \
     + prefixed_pr_message_footer
end

#pr_nameObject


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

def pr_name
  pr_name = pr_name_prefixer.pr_name_prefix
  pr_name += library? ? library_pr_name : application_pr_name
  return pr_name if files.first.directory == "/"

  pr_name + " in #{files.first.directory}"
end