Class: Dependabot::PullRequestCreator
- Inherits:
-
Object
- Object
- Dependabot::PullRequestCreator
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/pull_request_creator.rb,
lib/dependabot/pull_request_creator/azure.rb,
lib/dependabot/pull_request_creator/github.rb,
lib/dependabot/pull_request_creator/gitlab.rb,
lib/dependabot/pull_request_creator/labeler.rb,
lib/dependabot/pull_request_creator/message.rb,
lib/dependabot/pull_request_creator/bitbucket.rb,
lib/dependabot/pull_request_creator/codecommit.rb,
lib/dependabot/pull_request_creator/branch_namer.rb,
lib/dependabot/pull_request_creator/commit_signer.rb,
lib/dependabot/pull_request_creator/message_builder.rb,
lib/dependabot/pull_request_creator/pr_name_prefixer.rb,
lib/dependabot/pull_request_creator/branch_namer/base.rb,
lib/dependabot/pull_request_creator/branch_namer/solo_strategy.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/branch_namer/dependency_group_strategy.rb,
lib/dependabot/pull_request_creator/message_builder/link_and_mention_sanitizer.rb
Defined Under Namespace
Classes: AnnotationError, Azure, BaseCommitNotUpToDate, Bitbucket, BranchNamer, Codecommit, CommitSigner, Github, Gitlab, Labeler, Message, MessageBuilder, NoHistoryInCommon, PrNamePrefixer, RepoArchived, RepoDisabled, RepoNotFound, UnexpectedError, UnmergedPRExists
Constant Summary collapse
- DEFAULT_GITHUB_REDIRECTION_SERVICE =
Dependabot programmatically creates PRs which often include a large number of links to objects on ‘github.com`. GitHub hydrates these into rich links that leave a ’mention’ on target Issues/Pull Requests.
Due to the volume and nature of Dependabot PRs, these mentions are not useful and can overwhelm maintainers, so we use a redirection service to avoid enrichment.
If you wish to disable this behaviour when using Dependabot Core directly, pass a nil value when initialising this class.
"redirect.github.com"
- AzureReviewers =
T.type_alias { T.nilable(T::Array[String]) }
- GithubReviewers =
T.type_alias { T.nilable(T::Hash[String, T::Array[String]]) }
- GitLabReviewers =
T.type_alias { T.nilable(T::Hash[Symbol, T::Array[Integer]]) }
- Reviewers =
T.type_alias { T.any(AzureReviewers, GithubReviewers, GitLabReviewers) }
Instance Attribute Summary collapse
-
#assignees ⇒ Object
readonly
Returns the value of attribute assignees.
-
#author_details ⇒ Object
readonly
Returns the value of attribute author_details.
-
#base_commit ⇒ Object
readonly
Returns the value of attribute base_commit.
-
#branch_name_max_length ⇒ Object
readonly
Returns the value of attribute branch_name_max_length.
-
#branch_name_prefix ⇒ Object
readonly
Returns the value of attribute branch_name_prefix.
-
#branch_name_separator ⇒ Object
readonly
Returns the value of attribute branch_name_separator.
-
#commit_message_options ⇒ Object
readonly
Returns the value of attribute commit_message_options.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#custom_headers ⇒ Object
readonly
Returns the value of attribute custom_headers.
-
#custom_labels ⇒ Object
readonly
Returns the value of attribute custom_labels.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#dependency_group ⇒ Object
readonly
Returns the value of attribute dependency_group.
-
#existing_branches ⇒ Object
readonly
Returns the value of attribute existing_branches.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#github_redirection_service ⇒ Object
readonly
Returns the value of attribute github_redirection_service.
-
#milestone ⇒ Object
readonly
Returns the value of attribute milestone.
-
#pr_message_encoding ⇒ Object
readonly
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
readonly
Returns the value of attribute pr_message_max_length.
-
#provider_metadata ⇒ Object
readonly
Returns the value of attribute provider_metadata.
-
#reviewers ⇒ Object
readonly
Returns the value of attribute reviewers.
-
#signature_key ⇒ Object
readonly
Returns the value of attribute signature_key.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#vulnerabilities_fixed ⇒ Object
readonly
Returns the value of attribute vulnerabilities_fixed.
Instance Method Summary collapse
- #check_dependencies_have_previous_version ⇒ Object
- #create ⇒ Object
-
#initialize(source:, base_commit:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, custom_labels: nil, author_details: nil, signature_key: nil, commit_message_options: {}, vulnerabilities_fixed: {}, reviewers: nil, assignees: nil, milestone: nil, existing_branches: [], branch_name_separator: "/", branch_name_prefix: "dependabot", branch_name_max_length: nil, label_language: false, automerge_candidate: false, github_redirection_service: DEFAULT_GITHUB_REDIRECTION_SERVICE, custom_headers: nil, require_up_to_date_base: false, provider_metadata: {}, message: nil, dependency_group: nil, pr_message_max_length: nil, pr_message_encoding: nil) ⇒ PullRequestCreator
constructor
A new instance of PullRequestCreator.
Constructor Details
#initialize(source:, base_commit:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, custom_labels: nil, author_details: nil, signature_key: nil, commit_message_options: {}, vulnerabilities_fixed: {}, reviewers: nil, assignees: nil, milestone: nil, existing_branches: [], branch_name_separator: "/", branch_name_prefix: "dependabot", branch_name_max_length: nil, label_language: false, automerge_candidate: false, github_redirection_service: DEFAULT_GITHUB_REDIRECTION_SERVICE, custom_headers: nil, require_up_to_date_base: false, provider_metadata: {}, message: nil, dependency_group: nil, pr_message_max_length: nil, pr_message_encoding: nil) ⇒ PullRequestCreator
Returns a new instance of PullRequestCreator.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/dependabot/pull_request_creator.rb', line 184 def initialize(source:, base_commit:, dependencies:, files:, credentials:, pr_message_header: nil, pr_message_footer: nil, custom_labels: nil, author_details: nil, signature_key: nil, commit_message_options: {}, vulnerabilities_fixed: {}, reviewers: nil, assignees: nil, milestone: nil, existing_branches: [], branch_name_separator: "/", branch_name_prefix: "dependabot", branch_name_max_length: nil, label_language: false, automerge_candidate: false, github_redirection_service: DEFAULT_GITHUB_REDIRECTION_SERVICE, custom_headers: nil, require_up_to_date_base: false, provider_metadata: {}, message: nil, dependency_group: nil, pr_message_max_length: nil, pr_message_encoding: nil) @dependencies = dependencies @source = source @base_commit = base_commit @files = files @credentials = credentials @pr_message_header = @pr_message_footer = @author_details = @signature_key = signature_key @commit_message_options = @custom_labels = custom_labels @reviewers = reviewers @assignees = assignees @milestone = milestone @vulnerabilities_fixed = vulnerabilities_fixed @existing_branches = existing_branches @branch_name_separator = branch_name_separator @branch_name_prefix = branch_name_prefix @branch_name_max_length = branch_name_max_length @label_language = label_language @automerge_candidate = automerge_candidate @github_redirection_service = github_redirection_service @custom_headers = custom_headers @require_up_to_date_base = require_up_to_date_base @provider_metadata = @message = @dependency_group = dependency_group @pr_message_max_length = @pr_message_encoding = check_dependencies_have_previous_version end |
Instance Attribute Details
#assignees ⇒ Object (readonly)
Returns the value of attribute assignees.
113 114 115 |
# File 'lib/dependabot/pull_request_creator.rb', line 113 def assignees @assignees end |
#author_details ⇒ Object (readonly)
Returns the value of attribute author_details.
93 94 95 |
# File 'lib/dependabot/pull_request_creator.rb', line 93 def @author_details end |
#base_commit ⇒ Object (readonly)
Returns the value of attribute base_commit.
78 79 80 |
# File 'lib/dependabot/pull_request_creator.rb', line 78 def base_commit @base_commit end |
#branch_name_max_length ⇒ Object (readonly)
Returns the value of attribute branch_name_max_length.
128 129 130 |
# File 'lib/dependabot/pull_request_creator.rb', line 128 def branch_name_max_length @branch_name_max_length end |
#branch_name_prefix ⇒ Object (readonly)
Returns the value of attribute branch_name_prefix.
125 126 127 |
# File 'lib/dependabot/pull_request_creator.rb', line 125 def branch_name_prefix @branch_name_prefix end |
#branch_name_separator ⇒ Object (readonly)
Returns the value of attribute branch_name_separator.
122 123 124 |
# File 'lib/dependabot/pull_request_creator.rb', line 122 def branch_name_separator @branch_name_separator end |
#commit_message_options ⇒ Object (readonly)
Returns the value of attribute commit_message_options.
99 100 101 |
# File 'lib/dependabot/pull_request_creator.rb', line 99 def @commit_message_options end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
81 82 83 |
# File 'lib/dependabot/pull_request_creator.rb', line 81 def credentials @credentials end |
#custom_headers ⇒ Object (readonly)
Returns the value of attribute custom_headers.
134 135 136 |
# File 'lib/dependabot/pull_request_creator.rb', line 134 def custom_headers @custom_headers end |
#custom_labels ⇒ Object (readonly)
Returns the value of attribute custom_labels.
90 91 92 |
# File 'lib/dependabot/pull_request_creator.rb', line 90 def custom_labels @custom_labels end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
72 73 74 |
# File 'lib/dependabot/pull_request_creator.rb', line 72 def dependencies @dependencies end |
#dependency_group ⇒ Object (readonly)
Returns the value of attribute dependency_group.
140 141 142 |
# File 'lib/dependabot/pull_request_creator.rb', line 140 def dependency_group @dependency_group end |
#existing_branches ⇒ Object (readonly)
Returns the value of attribute existing_branches.
119 120 121 |
# File 'lib/dependabot/pull_request_creator.rb', line 119 def existing_branches @existing_branches end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
75 76 77 |
# File 'lib/dependabot/pull_request_creator.rb', line 75 def files @files end |
#github_redirection_service ⇒ Object (readonly)
Returns the value of attribute github_redirection_service.
131 132 133 |
# File 'lib/dependabot/pull_request_creator.rb', line 131 def github_redirection_service @github_redirection_service end |
#milestone ⇒ Object (readonly)
Returns the value of attribute milestone.
116 117 118 |
# File 'lib/dependabot/pull_request_creator.rb', line 116 def milestone @milestone end |
#pr_message_encoding ⇒ Object (readonly)
Returns the value of attribute pr_message_encoding.
146 147 148 |
# File 'lib/dependabot/pull_request_creator.rb', line 146 def @pr_message_encoding end |
#pr_message_footer ⇒ Object (readonly)
Returns the value of attribute pr_message_footer.
87 88 89 |
# File 'lib/dependabot/pull_request_creator.rb', line 87 def @pr_message_footer end |
#pr_message_header ⇒ Object (readonly)
Returns the value of attribute pr_message_header.
84 85 86 |
# File 'lib/dependabot/pull_request_creator.rb', line 84 def @pr_message_header end |
#pr_message_max_length ⇒ Object (readonly)
Returns the value of attribute pr_message_max_length.
143 144 145 |
# File 'lib/dependabot/pull_request_creator.rb', line 143 def @pr_message_max_length end |
#provider_metadata ⇒ Object (readonly)
Returns the value of attribute provider_metadata.
137 138 139 |
# File 'lib/dependabot/pull_request_creator.rb', line 137 def @provider_metadata end |
#reviewers ⇒ Object (readonly)
Returns the value of attribute reviewers.
110 111 112 |
# File 'lib/dependabot/pull_request_creator.rb', line 110 def reviewers @reviewers end |
#signature_key ⇒ Object (readonly)
Returns the value of attribute signature_key.
96 97 98 |
# File 'lib/dependabot/pull_request_creator.rb', line 96 def signature_key @signature_key end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
69 70 71 |
# File 'lib/dependabot/pull_request_creator.rb', line 69 def source @source end |
#vulnerabilities_fixed ⇒ Object (readonly)
Returns the value of attribute vulnerabilities_fixed.
102 103 104 |
# File 'lib/dependabot/pull_request_creator.rb', line 102 def vulnerabilities_fixed @vulnerabilities_fixed end |
Instance Method Details
#check_dependencies_have_previous_version ⇒ Object
230 231 232 233 234 235 236 |
# File 'lib/dependabot/pull_request_creator.rb', line 230 def check_dependencies_have_previous_version return if dependencies.all? { |d| requirements_changed?(d) } return if dependencies.all?(&:previous_version) raise "Dependencies must have a previous version or changed " \ "requirement to have a pull request created for them!" end |
#create ⇒ Object
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/dependabot/pull_request_creator.rb', line 242 def create case source.provider when "github" then github_creator.create when "gitlab" then gitlab_creator.create when "azure" then azure_creator.create when "bitbucket" then bitbucket_creator.create when "codecommit" then codecommit_creator.create else raise "Unsupported provider #{source.provider}" end end |