Class: Dependabot::PullRequestCreator::MessageBuilder
- Inherits:
-
Object
- Object
- Dependabot::PullRequestCreator::MessageBuilder
- Extended by:
- T::Sig
- 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/title_builder.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, TitleBuilder
Constant Summary collapse
- TRUNCATED_MSG =
"...\n\n_Description has been truncated_"
Instance Attribute Summary collapse
-
#commit_message_options ⇒ Object
readonly
Returns the value of attribute commit_message_options.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#dependency_group ⇒ Object
readonly
Returns the value of attribute dependency_group.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#github_redirection_service ⇒ Object
readonly
Returns the value of attribute github_redirection_service.
-
#ignore_conditions ⇒ Object
readonly
Returns the value of attribute ignore_conditions.
-
#notices ⇒ Object
readonly
Returns the value of attribute notices.
-
#pr_message_encoding ⇒ Object
Returns the value of attribute pr_message_encoding.
-
#pr_message_footer ⇒ Object
readonly
Returns the value of attribute pr_message_footer.
-
#pr_message_header ⇒ Object
readonly
Returns the value of attribute pr_message_header.
-
#pr_message_max_length ⇒ Object
Returns the value of attribute pr_message_max_length.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#vulnerabilities_fixed ⇒ Object
readonly
Returns the value of attribute vulnerabilities_fixed.
Instance Method Summary collapse
- #commit_message ⇒ Object
-
#initialize(source:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, commit_message_options: {}, vulnerabilities_fixed: {}, github_redirection_service: DEFAULT_GITHUB_REDIRECTION_SERVICE, dependency_group: nil, pr_message_max_length: nil, pr_message_encoding: nil, ignore_conditions: [], notices: nil) ⇒ MessageBuilder
constructor
A new instance of MessageBuilder.
- #message ⇒ Object
- #pr_message ⇒ Object
- #pr_name ⇒ Object
- #pr_notices ⇒ Object
- #truncate_pr_message(msg) ⇒ Object
Constructor Details
#initialize(source:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, commit_message_options: {}, vulnerabilities_fixed: {}, github_redirection_service: DEFAULT_GITHUB_REDIRECTION_SERVICE, dependency_group: nil, pr_message_max_length: nil, pr_message_encoding: nil, ignore_conditions: [], notices: nil) ⇒ MessageBuilder
Returns a new instance of MessageBuilder.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 93 def initialize( source:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, commit_message_options: {}, vulnerabilities_fixed: {}, github_redirection_service: DEFAULT_GITHUB_REDIRECTION_SERVICE, dependency_group: nil, pr_message_max_length: nil, pr_message_encoding: nil, ignore_conditions: [], notices: nil ) @dependencies = dependencies @files = files @source = source @credentials = credentials @pr_message_header = @pr_message_footer = @commit_message_options = @vulnerabilities_fixed = vulnerabilities_fixed @github_redirection_service = github_redirection_service @dependency_group = dependency_group @pr_message_max_length = @pr_message_encoding = @ignore_conditions = ignore_conditions @notices = notices end |
Instance Attribute Details
#commit_message_options ⇒ Object (readonly)
Returns the value of attribute commit_message_options.
49 50 51 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 49 def @commit_message_options end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
40 41 42 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 40 def credentials @credentials end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
34 35 36 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 34 def dependencies @dependencies end |
#dependency_group ⇒ Object (readonly)
Returns the value of attribute dependency_group.
58 59 60 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 58 def dependency_group @dependency_group end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
37 38 39 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 37 def files @files end |
#github_redirection_service ⇒ Object (readonly)
Returns the value of attribute github_redirection_service.
55 56 57 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 55 def github_redirection_service @github_redirection_service end |
#ignore_conditions ⇒ Object (readonly)
Returns the value of attribute ignore_conditions.
67 68 69 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 67 def ignore_conditions @ignore_conditions end |
#notices ⇒ Object (readonly)
Returns the value of attribute notices.
70 71 72 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 70 def notices @notices end |
#pr_message_encoding ⇒ Object
Returns the value of attribute pr_message_encoding.
64 65 66 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 64 def @pr_message_encoding end |
#pr_message_footer ⇒ Object (readonly)
Returns the value of attribute pr_message_footer.
46 47 48 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 46 def @pr_message_footer end |
#pr_message_header ⇒ Object (readonly)
Returns the value of attribute pr_message_header.
43 44 45 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 43 def @pr_message_header end |
#pr_message_max_length ⇒ Object
Returns the value of attribute pr_message_max_length.
61 62 63 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 61 def @pr_message_max_length end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
31 32 33 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 31 def source @source end |
#vulnerabilities_fixed ⇒ Object (readonly)
Returns the value of attribute vulnerabilities_fixed.
52 53 54 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 52 def vulnerabilities_fixed @vulnerabilities_fixed end |
Instance Method Details
#commit_message ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 190 def = commit_subject + "\n\n" += += += "\n\n" + T.must() if rescue StandardError => e suppress_error("commit message", e) = commit_subject += "\n\n" + T.must() if end |
#message ⇒ Object
204 205 206 207 208 209 210 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 204 def Dependabot::PullRequestCreator::Message.new( pr_name: pr_name, pr_message: , commit_message: ) end |
#pr_message ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 141 def msg = "#{pr_notices}" \ "#{}" \ "#{}" \ "#{}" \ "#{ignore_conditions_table}" \ "#{}" (msg) rescue StandardError => e suppress_error("PR message", e) + end |
#pr_name ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 132 def pr_name name = dependency_group ? group_pr_name : solo_pr_name MessageBuilder::TitleBuilder.new( base_title: name, prefixer: pr_name_prefixer ).build end |
#pr_notices ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 156 def pr_notices notices = @notices || [] = notices.filter_map do |notice| Dependabot::Notice.markdown_from_description(notice) if notice.show_in_pr end.uniq = .join("\n\n") .empty? ? nil : end |
#truncate_pr_message(msg) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/dependabot/pull_request_creator/message_builder.rb', line 169 def (msg) return msg if .nil? msg = msg.dup msg = msg.force_encoding(T.must()) unless .nil? if msg.length > T.must() tr_msg = if .nil? TRUNCATED_MSG else (+TRUNCATED_MSG).dup.force_encoding(T.must()) end trunc_length = T.must() - tr_msg.length msg = (T.must(msg[0..trunc_length]) + tr_msg) end # if we used a custom encoding for calculating length, then we need to force back to UTF-8 msg = msg.encode("utf-8", "binary", invalid: :replace, undef: :replace) unless .nil? msg end |