dependabot-common 0.112.35 → 0.113.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dependabot/clients/codecommit.rb +198 -0
- data/lib/dependabot/file_fetchers/base.rb +33 -1
- data/lib/dependabot/pull_request_creator.rb +18 -0
- data/lib/dependabot/pull_request_creator/codecommit.rb +144 -0
- data/lib/dependabot/pull_request_creator/commit_signer.rb +7 -1
- data/lib/dependabot/pull_request_creator/message_builder.rb +2 -1
- data/lib/dependabot/pull_request_creator/pr_name_prefixer.rb +32 -0
- data/lib/dependabot/source.rb +12 -5
- data/lib/dependabot/version.rb +1 -1
- metadata +32 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d98838d69b22779567c2db929a41d583e33001e3c8fbd8e7895d598a52c8a31
|
4
|
+
data.tar.gz: 91814e2d00dd486eb37bae7bff1bf738166ffd9560c52afd6b49769ae396bc24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e947e065a6a846a1ad7455546bba80fcc51b537d1d42d781c5ba84fced5cb69f8484ce260b7139cc31f9f04914ce9eb403b573d32ec0897b027d0d9dba60971
|
7
|
+
data.tar.gz: 28d378e61173d3773848c54b539d29d6a970e79d4279857bd52f7ebf25691676866980541b967d6fb8f24eba152b821ec55c92e06d48182cfe6505cf533a9bde
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dependabot/shared_helpers"
|
4
|
+
|
5
|
+
module Dependabot
|
6
|
+
module Clients
|
7
|
+
class CodeCommit
|
8
|
+
class NotFound < StandardError; end
|
9
|
+
|
10
|
+
#######################
|
11
|
+
# Constructor methods #
|
12
|
+
#######################
|
13
|
+
|
14
|
+
def self.for_source(source:, credentials:)
|
15
|
+
credential =
|
16
|
+
credentials.
|
17
|
+
select { |cred| cred["type"] == "git_source" }.
|
18
|
+
find { |cred| cred["region"] == source.hostname }
|
19
|
+
|
20
|
+
new(source, credential)
|
21
|
+
end
|
22
|
+
|
23
|
+
##########
|
24
|
+
# Client #
|
25
|
+
##########
|
26
|
+
|
27
|
+
def initialize(source, credentials)
|
28
|
+
@source = source
|
29
|
+
@cc_client = Aws::CodeCommit::Client.new(
|
30
|
+
access_key_id: credentials&.fetch("username"),
|
31
|
+
secret_access_key: credentials&.fetch("password"),
|
32
|
+
region: credentials&.fetch("region")
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def fetch_commit(repo, branch)
|
37
|
+
cc_client.get_branch(
|
38
|
+
branch_name: branch,
|
39
|
+
repository_name: repo
|
40
|
+
).branch.commit_id
|
41
|
+
end
|
42
|
+
|
43
|
+
def fetch_default_branch(repo)
|
44
|
+
cc_client.get_repository(
|
45
|
+
repository_name: repo
|
46
|
+
).repository_metadata.default_branch
|
47
|
+
end
|
48
|
+
|
49
|
+
def fetch_repo_contents(repo, commit = nil, path = nil)
|
50
|
+
actual_path = path
|
51
|
+
actual_path = "/" if path.to_s.empty?
|
52
|
+
|
53
|
+
cc_client.get_folder(
|
54
|
+
repository_name: repo,
|
55
|
+
commit_specifier: commit,
|
56
|
+
folder_path: actual_path
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def fetch_file_contents(repo, commit, path)
|
61
|
+
cc_client.get_file(
|
62
|
+
repository_name: repo,
|
63
|
+
commit_specifier: commit,
|
64
|
+
file_path: path
|
65
|
+
).file_content
|
66
|
+
rescue Aws::CodeCommit::Errors::FileDoesNotExistException
|
67
|
+
raise NotFound
|
68
|
+
end
|
69
|
+
|
70
|
+
def branch(branch_name)
|
71
|
+
cc_client.get_branch(
|
72
|
+
repository_name: source.unscoped_repo,
|
73
|
+
branch_name: branch_name
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# work around b/c codecommit doesn't have a 'get all commits' api..
|
78
|
+
def fetch_commits(repo, branch_name, result_count)
|
79
|
+
top_commit = fetch_commit(repo, branch_name)
|
80
|
+
retrieved_commits = []
|
81
|
+
pending_commits = []
|
82
|
+
|
83
|
+
# get the parent commit ids from the latest commit on the default branch
|
84
|
+
latest_commit = @cc_client.get_commit(
|
85
|
+
repository_name: repo,
|
86
|
+
commit_id: top_commit
|
87
|
+
)
|
88
|
+
|
89
|
+
# add the parent commit ids to the pending_commits array
|
90
|
+
pending_commits.push(*latest_commit.commit.parents)
|
91
|
+
|
92
|
+
# iterate over the array of pending commits and
|
93
|
+
# get each of the corresponding parent commits
|
94
|
+
until pending_commits.empty? || retrieved_commits.count > result_count
|
95
|
+
commit_id = pending_commits[0]
|
96
|
+
|
97
|
+
# get any parent commits from the provided commit
|
98
|
+
parent_commits = @cc_client.get_commit(
|
99
|
+
repository_name: repo,
|
100
|
+
commit_id: commit_id
|
101
|
+
)
|
102
|
+
|
103
|
+
# remove the previously retrieved_commits
|
104
|
+
# form the pending_commits array
|
105
|
+
pending_commits.delete(commit_id)
|
106
|
+
# add the commit id to the retrieved_commits array
|
107
|
+
retrieved_commits << commit_id
|
108
|
+
# add the retrieved parent commits to the pending_commits array
|
109
|
+
pending_commits.push(*parent_commits.commit.parents)
|
110
|
+
end
|
111
|
+
|
112
|
+
retrieved_commits << top_commit
|
113
|
+
result = retrieved_commits | pending_commits
|
114
|
+
result
|
115
|
+
end
|
116
|
+
|
117
|
+
def commits(repo, branch_name = source.branch)
|
118
|
+
retrieved_commits = fetch_commits(repo, branch_name, 5)
|
119
|
+
|
120
|
+
result = @cc_client.batch_get_commits(
|
121
|
+
commit_ids: retrieved_commits,
|
122
|
+
repository_name: repo
|
123
|
+
)
|
124
|
+
|
125
|
+
# sort the results by date
|
126
|
+
result.commits.sort! { |a, b| b.author.date <=> a.author.date }
|
127
|
+
result
|
128
|
+
end
|
129
|
+
|
130
|
+
def pull_requests(repo, state, branch)
|
131
|
+
pull_request_ids = @cc_client.list_pull_requests(
|
132
|
+
repository_name: repo,
|
133
|
+
pull_request_status: state
|
134
|
+
).pull_request_ids
|
135
|
+
|
136
|
+
result = []
|
137
|
+
# list_pull_requests only gets us the pull request id
|
138
|
+
# get_pull_request has all the info we need
|
139
|
+
pull_request_ids.each do |id|
|
140
|
+
pr_hash = @cc_client.get_pull_request(
|
141
|
+
pull_request_id: id
|
142
|
+
)
|
143
|
+
# only include PRs from the referenced branch
|
144
|
+
if pr_hash.pull_request.pull_request_targets[0].
|
145
|
+
source_reference.include? branch
|
146
|
+
result << pr_hash
|
147
|
+
end
|
148
|
+
end
|
149
|
+
result
|
150
|
+
end
|
151
|
+
|
152
|
+
def create_branch(repo, branch_name, commit_id)
|
153
|
+
cc_client.create_branch(
|
154
|
+
repository_name: repo,
|
155
|
+
branch_name: branch_name,
|
156
|
+
commit_id: commit_id
|
157
|
+
)
|
158
|
+
end
|
159
|
+
|
160
|
+
def create_commit(branch_name, author_name, base_commit, commit_message,
|
161
|
+
files)
|
162
|
+
cc_client.create_commit(
|
163
|
+
repository_name: source.unscoped_repo,
|
164
|
+
branch_name: branch_name,
|
165
|
+
parent_commit_id: base_commit,
|
166
|
+
author_name: author_name,
|
167
|
+
commit_message: commit_message,
|
168
|
+
put_files: files.map do |file|
|
169
|
+
{
|
170
|
+
file_path: file.path,
|
171
|
+
file_mode: "NORMAL",
|
172
|
+
file_content: file.content
|
173
|
+
}
|
174
|
+
end
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
def create_pull_request(pr_name, target_branch, source_branch,
|
179
|
+
pr_description)
|
180
|
+
cc_client.create_pull_request(
|
181
|
+
title: pr_name,
|
182
|
+
description: pr_description,
|
183
|
+
targets: [
|
184
|
+
repository_name: source.unscoped_repo,
|
185
|
+
source_reference: target_branch,
|
186
|
+
destination_reference: source_branch
|
187
|
+
]
|
188
|
+
)
|
189
|
+
end
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
attr_reader :credentials
|
194
|
+
attr_reader :source
|
195
|
+
attr_reader :cc_client
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -4,6 +4,7 @@ require "dependabot/dependency_file"
|
|
4
4
|
require "dependabot/source"
|
5
5
|
require "dependabot/errors"
|
6
6
|
require "dependabot/clients/azure"
|
7
|
+
require "dependabot/clients/codecommit"
|
7
8
|
require "dependabot/clients/github_with_retries"
|
8
9
|
require "dependabot/clients/bitbucket_with_retries"
|
9
10
|
require "dependabot/clients/gitlab_with_retries"
|
@@ -19,7 +20,8 @@ module Dependabot
|
|
19
20
|
Octokit::NotFound,
|
20
21
|
Gitlab::Error::NotFound,
|
21
22
|
Dependabot::Clients::Azure::NotFound,
|
22
|
-
Dependabot::Clients::Bitbucket::NotFound
|
23
|
+
Dependabot::Clients::Bitbucket::NotFound,
|
24
|
+
Dependabot::Clients::CodeCommit::NotFound
|
23
25
|
].freeze
|
24
26
|
|
25
27
|
def self.required_files_in?(_filename_array)
|
@@ -54,6 +56,8 @@ module Dependabot
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def commit
|
59
|
+
return source.commit if source.commit
|
60
|
+
|
57
61
|
branch = target_branch || default_branch_for_repo
|
58
62
|
|
59
63
|
@commit ||= client_for_provider.fetch_commit(repo, branch)
|
@@ -153,6 +157,8 @@ module Dependabot
|
|
153
157
|
_azure_repo_contents(path, commit)
|
154
158
|
when "bitbucket"
|
155
159
|
_bitbucket_repo_contents(repo, path, commit)
|
160
|
+
when "codecommit"
|
161
|
+
_codecommit_repo_contents(repo, path, commit)
|
156
162
|
else raise "Unsupported provider '#{provider}'."
|
157
163
|
end
|
158
164
|
end
|
@@ -263,6 +269,23 @@ module Dependabot
|
|
263
269
|
end
|
264
270
|
end
|
265
271
|
|
272
|
+
def _codecommit_repo_contents(repo, path, commit)
|
273
|
+
response = codecommit_client.fetch_repo_contents(
|
274
|
+
repo,
|
275
|
+
commit,
|
276
|
+
path
|
277
|
+
)
|
278
|
+
|
279
|
+
response.files.map do |file|
|
280
|
+
OpenStruct.new(
|
281
|
+
name: file.absolute_path,
|
282
|
+
path: file.absolute_path,
|
283
|
+
type: "file",
|
284
|
+
size: 0 # file size would require new api call per file..
|
285
|
+
)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
266
289
|
def _full_specification_for(path, fetch_submodules:)
|
267
290
|
if fetch_submodules && _linked_dir_for(path)
|
268
291
|
linked_dir_details = @linked_paths[_linked_dir_for(path)]
|
@@ -319,6 +342,8 @@ module Dependabot
|
|
319
342
|
azure_client.fetch_file_contents(commit, path)
|
320
343
|
when "bitbucket"
|
321
344
|
bitbucket_client.fetch_file_contents(repo, commit, path)
|
345
|
+
when "codecommit"
|
346
|
+
codecommit_client.fetch_file_contents(repo, commit, path)
|
322
347
|
else raise "Unsupported provider '#{source.provider}'."
|
323
348
|
end
|
324
349
|
end
|
@@ -400,6 +425,7 @@ module Dependabot
|
|
400
425
|
when "gitlab" then gitlab_client
|
401
426
|
when "azure" then azure_client
|
402
427
|
when "bitbucket" then bitbucket_client
|
428
|
+
when "codecommit" then codecommit_client
|
403
429
|
else raise "Unsupported provider '#{source.provider}'."
|
404
430
|
end
|
405
431
|
end
|
@@ -433,6 +459,12 @@ module Dependabot
|
|
433
459
|
Dependabot::Clients::BitbucketWithRetries.
|
434
460
|
for_bitbucket_dot_org(credentials: credentials)
|
435
461
|
end
|
462
|
+
|
463
|
+
def codecommit_client
|
464
|
+
@codecommit_client ||=
|
465
|
+
Dependabot::Clients::CodeCommit.
|
466
|
+
for_source(source: source, credentials: credentials)
|
467
|
+
end
|
436
468
|
end
|
437
469
|
end
|
438
470
|
end
|
@@ -5,6 +5,7 @@ require "dependabot/metadata_finders"
|
|
5
5
|
module Dependabot
|
6
6
|
class PullRequestCreator
|
7
7
|
require "dependabot/pull_request_creator/azure"
|
8
|
+
require "dependabot/pull_request_creator/codecommit"
|
8
9
|
require "dependabot/pull_request_creator/github"
|
9
10
|
require "dependabot/pull_request_creator/gitlab"
|
10
11
|
require "dependabot/pull_request_creator/message_builder"
|
@@ -71,6 +72,7 @@ module Dependabot
|
|
71
72
|
when "github" then github_creator.create
|
72
73
|
when "gitlab" then gitlab_creator.create
|
73
74
|
when "azure" then azure_creator.create
|
75
|
+
when "codecommit" then codecommit_creator.create
|
74
76
|
else raise "Unsupported provider #{source.provider}"
|
75
77
|
end
|
76
78
|
end
|
@@ -143,6 +145,22 @@ module Dependabot
|
|
143
145
|
)
|
144
146
|
end
|
145
147
|
|
148
|
+
def codecommit_creator
|
149
|
+
Codecommit.new(
|
150
|
+
source: source,
|
151
|
+
branch_name: branch_namer.new_branch_name,
|
152
|
+
base_commit: base_commit,
|
153
|
+
credentials: credentials,
|
154
|
+
files: files,
|
155
|
+
commit_message: message_builder.commit_message,
|
156
|
+
pr_description: message_builder.pr_message,
|
157
|
+
pr_name: message_builder.pr_name,
|
158
|
+
author_details: author_details,
|
159
|
+
labeler: labeler,
|
160
|
+
require_up_to_date_base: require_up_to_date_base?
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
146
164
|
def message_builder
|
147
165
|
@message_builder ||
|
148
166
|
MessageBuilder.new(
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dependabot/clients/codecommit"
|
4
|
+
require "dependabot/pull_request_creator"
|
5
|
+
|
6
|
+
module Dependabot
|
7
|
+
class PullRequestCreator
|
8
|
+
class Codecommit
|
9
|
+
attr_reader :source, :branch_name, :base_commit, :credentials,
|
10
|
+
:files, :commit_message, :pr_description, :pr_name,
|
11
|
+
:author_details, :labeler
|
12
|
+
|
13
|
+
def initialize(source:, branch_name:, base_commit:, credentials:,
|
14
|
+
files:, commit_message:, pr_description:, pr_name:,
|
15
|
+
author_details:, labeler:, require_up_to_date_base:)
|
16
|
+
@source = source
|
17
|
+
@branch_name = branch_name
|
18
|
+
@base_commit = base_commit
|
19
|
+
@credentials = credentials
|
20
|
+
@files = files
|
21
|
+
@commit_message = commit_message
|
22
|
+
@pr_description = pr_description
|
23
|
+
@pr_name = pr_name
|
24
|
+
@author_details = author_details
|
25
|
+
@labeler = labeler
|
26
|
+
@require_up_to_date_base = require_up_to_date_base
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
return if branch_exists?(branch_name) && unmerged_pull_request_exists?
|
31
|
+
return if require_up_to_date_base? && !base_commit_is_up_to_date?
|
32
|
+
|
33
|
+
create_pull_request
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def require_up_to_date_base?
|
39
|
+
@require_up_to_date_base
|
40
|
+
end
|
41
|
+
|
42
|
+
def base_commit_is_up_to_date?
|
43
|
+
codecommit_client_for_source.fetch_commit(
|
44
|
+
source.repo,
|
45
|
+
branch_name
|
46
|
+
) == base_commit
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_pull_request
|
50
|
+
branch = create_or_get_branch(base_commit)
|
51
|
+
return unless branch
|
52
|
+
|
53
|
+
pull_request = codecommit_client_for_source.create_pull_request(
|
54
|
+
pr_name,
|
55
|
+
branch_name,
|
56
|
+
source.branch || default_branch,
|
57
|
+
pr_description
|
58
|
+
# codecommit doesn't support PR lables
|
59
|
+
)
|
60
|
+
return unless pull_request
|
61
|
+
|
62
|
+
pull_request
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_or_get_branch(commit)
|
66
|
+
# returns the branch name
|
67
|
+
if branch_exists?(branch_name)
|
68
|
+
branch_name
|
69
|
+
else
|
70
|
+
create_branch(commit)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_branch(commit)
|
75
|
+
# codecommit returns an empty response on create branch success
|
76
|
+
codecommit_client_for_source.create_branch(source.repo, branch_name,
|
77
|
+
commit)
|
78
|
+
@branch_name = branch_name
|
79
|
+
branch_name
|
80
|
+
end
|
81
|
+
|
82
|
+
def codecommit_client_for_source
|
83
|
+
@codecommit_client_for_source ||=
|
84
|
+
Dependabot::Clients::CodeCommit.for_source(
|
85
|
+
source: source,
|
86
|
+
credentials: credentials
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def branch_exists?(branch_name)
|
91
|
+
@branch_ref ||= codecommit_client_for_source.branch(branch_name)
|
92
|
+
rescue Aws::CodeCommit::Errors::BranchDoesNotExistException
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
def unmerged_pull_request_exists?
|
97
|
+
unmerged_prs = []
|
98
|
+
pull_requests_for_branch.each do |pr|
|
99
|
+
unless pr.pull_request.
|
100
|
+
pull_request_targets[0].merge_metadata.is_merged
|
101
|
+
unmerged_prs << pr
|
102
|
+
end
|
103
|
+
end
|
104
|
+
unmerged_prs.any?
|
105
|
+
end
|
106
|
+
|
107
|
+
def pull_requests_for_branch
|
108
|
+
@pull_requests_for_branch ||=
|
109
|
+
begin
|
110
|
+
open_prs = codecommit_client_for_source.pull_requests(
|
111
|
+
source.repo,
|
112
|
+
"open",
|
113
|
+
source.branch || default_branch
|
114
|
+
)
|
115
|
+
closed_prs = codecommit_client_for_source.pull_requests(
|
116
|
+
source.repo,
|
117
|
+
"closed",
|
118
|
+
source.branch || default_branch
|
119
|
+
)
|
120
|
+
|
121
|
+
[*open_prs, *closed_prs]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def create_commit
|
126
|
+
author = author_details&.slice(:name, :email, :date)
|
127
|
+
author = nil unless author&.any?
|
128
|
+
|
129
|
+
codecommit_client_for_source.create_commit(
|
130
|
+
branch_name,
|
131
|
+
author,
|
132
|
+
base_commit,
|
133
|
+
commit_message,
|
134
|
+
files
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
def default_branch
|
139
|
+
@default_branch ||=
|
140
|
+
codecommit_client_for_source.fetch_default_branch(source.repo)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "time"
|
4
|
-
require "gpgme"
|
5
4
|
require "tmpdir"
|
6
5
|
require "dependabot/pull_request_creator"
|
7
6
|
|
@@ -21,6 +20,13 @@ module Dependabot
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def signature
|
23
|
+
begin
|
24
|
+
require "gpgme"
|
25
|
+
rescue LoadError
|
26
|
+
raise LoadError, "Please add `gpgme` to your Gemfile or gemspec " \
|
27
|
+
"enable commit signatures"
|
28
|
+
end
|
29
|
+
|
24
30
|
email = author_details[:email]
|
25
31
|
|
26
32
|
dir = Dir.mktmpdir
|
@@ -424,7 +424,8 @@ module Dependabot
|
|
424
424
|
|
425
425
|
def build_details_tag(summary:, body:)
|
426
426
|
# Azure DevOps does not support <details> tag (https://developercommunity.visualstudio.com/content/problem/608769/add-support-for-in-markdown.html)
|
427
|
-
|
427
|
+
# CodeCommit does not support the <details> tag (no url available)
|
428
|
+
if source.provider == ("azure" || "codecommit")
|
428
429
|
"\n\##{summary}\n\n#{body}"
|
429
430
|
else
|
430
431
|
msg = "\n<details>\n<summary>#{summary}</summary>\n\n"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "dependabot/clients/azure"
|
4
|
+
require "dependabot/clients/codecommit"
|
4
5
|
require "dependabot/clients/github_with_retries"
|
5
6
|
require "dependabot/clients/gitlab_with_retries"
|
6
7
|
require "dependabot/pull_request_creator"
|
@@ -279,6 +280,7 @@ module Dependabot
|
|
279
280
|
when "github" then recent_github_commit_messages
|
280
281
|
when "gitlab" then recent_gitlab_commit_messages
|
281
282
|
when "azure" then recent_azure_commit_messages
|
283
|
+
when "codecommit" then recent_codecommit_commit_messages
|
282
284
|
else raise "Unsupported provider: #{source.provider}"
|
283
285
|
end
|
284
286
|
end
|
@@ -321,12 +323,24 @@ module Dependabot
|
|
321
323
|
map(&:strip)
|
322
324
|
end
|
323
325
|
|
326
|
+
def recent_codecommit_commit_messages
|
327
|
+
@recent_codecommit_commit_messages ||=
|
328
|
+
codecommit_client_for_source.commits
|
329
|
+
@recent_codecommit_commit_messages.commits.
|
330
|
+
reject { |c| c.author.email == dependabot_email }.
|
331
|
+
reject { |c| c.message&.start_with?("Merge") }.
|
332
|
+
map(&:message).
|
333
|
+
compact.
|
334
|
+
map(&:strip)
|
335
|
+
end
|
336
|
+
|
324
337
|
def last_dependabot_commit_message
|
325
338
|
@last_dependabot_commit_message ||=
|
326
339
|
case source.provider
|
327
340
|
when "github" then last_github_dependabot_commit_message
|
328
341
|
when "gitlab" then last_gitlab_dependabot_commit_message
|
329
342
|
when "azure" then last_azure_dependabot_commit_message
|
343
|
+
when "codecommit" then last_codecommit_dependabot_commit_message
|
330
344
|
else raise "Unsupported provider: #{source.provider}"
|
331
345
|
end
|
332
346
|
end
|
@@ -367,6 +381,16 @@ module Dependabot
|
|
367
381
|
strip
|
368
382
|
end
|
369
383
|
|
384
|
+
def last_codecommit_dependabot_commit_message
|
385
|
+
@recent_codecommit_commit_messages ||=
|
386
|
+
codecommit_client_for_source.commits(source.repo)
|
387
|
+
|
388
|
+
@recent_codecommit_commit_messages.commits.
|
389
|
+
find { |c| c.author.email == dependabot_email }&.
|
390
|
+
message&.
|
391
|
+
strip
|
392
|
+
end
|
393
|
+
|
370
394
|
def github_client_for_source
|
371
395
|
@github_client_for_source ||=
|
372
396
|
Dependabot::Clients::GithubWithRetries.for_source(
|
@@ -391,6 +415,14 @@ module Dependabot
|
|
391
415
|
)
|
392
416
|
end
|
393
417
|
|
418
|
+
def codecommit_client_for_source
|
419
|
+
@codecommit_client_for_source ||=
|
420
|
+
Dependabot::Clients::CodeCommit.for_source(
|
421
|
+
source: source,
|
422
|
+
credentials: credentials
|
423
|
+
)
|
424
|
+
end
|
425
|
+
|
394
426
|
def package_manager
|
395
427
|
@package_manager ||= dependencies.first.package_manager
|
396
428
|
end
|
data/lib/dependabot/source.rb
CHANGED
@@ -36,8 +36,8 @@ module Dependabot
|
|
36
36
|
(?:#{AZURE_SOURCE})
|
37
37
|
/x.freeze
|
38
38
|
|
39
|
-
attr_accessor :provider, :repo, :directory, :branch, :
|
40
|
-
:api_endpoint
|
39
|
+
attr_accessor :provider, :repo, :directory, :branch, :commit,
|
40
|
+
:hostname, :api_endpoint
|
41
41
|
|
42
42
|
def self.from_url(url_string)
|
43
43
|
return unless url_string&.match?(SOURCE_REGEX)
|
@@ -52,9 +52,9 @@ module Dependabot
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
-
def initialize(provider:, repo:, directory: nil, branch: nil,
|
56
|
-
api_endpoint: nil)
|
57
|
-
if hostname.nil? ^ api_endpoint.nil?
|
55
|
+
def initialize(provider:, repo:, directory: nil, branch: nil, commit: nil,
|
56
|
+
hostname: nil, api_endpoint: nil)
|
57
|
+
if (hostname.nil? ^ api_endpoint.nil?) && (provider != "codecommit")
|
58
58
|
msg = "Both hostname and api_endpoint must be specified if either "\
|
59
59
|
"are. Alternatively, both may be left blank to use the "\
|
60
60
|
"provider's defaults."
|
@@ -65,6 +65,7 @@ module Dependabot
|
|
65
65
|
@repo = repo
|
66
66
|
@directory = directory
|
67
67
|
@branch = branch
|
68
|
+
@commit = commit
|
68
69
|
@hostname = hostname || default_hostname(provider)
|
69
70
|
@api_endpoint = api_endpoint || default_api_endpoint(provider)
|
70
71
|
end
|
@@ -73,6 +74,7 @@ module Dependabot
|
|
73
74
|
"https://" + hostname + "/" + repo
|
74
75
|
end
|
75
76
|
|
77
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
76
78
|
def url_with_directory
|
77
79
|
return url if [nil, ".", "/"].include?(directory)
|
78
80
|
|
@@ -87,9 +89,12 @@ module Dependabot
|
|
87
89
|
url + "/" + path
|
88
90
|
when "azure"
|
89
91
|
url + "?path=#{directory}"
|
92
|
+
when "codecommit"
|
93
|
+
raise "The codecommit provider does not utilize URLs"
|
90
94
|
else raise "Unexpected repo provider '#{provider}'"
|
91
95
|
end
|
92
96
|
end
|
97
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
93
98
|
|
94
99
|
def organization
|
95
100
|
repo.split("/").first
|
@@ -116,6 +121,7 @@ module Dependabot
|
|
116
121
|
when "bitbucket" then "bitbucket.org"
|
117
122
|
when "gitlab" then "gitlab.com"
|
118
123
|
when "azure" then "dev.azure.com"
|
124
|
+
when "codecommit" then "us-east-1"
|
119
125
|
else raise "Unexpected provider '#{provider}'"
|
120
126
|
end
|
121
127
|
end
|
@@ -126,6 +132,7 @@ module Dependabot
|
|
126
132
|
when "bitbucket" then "https://api.bitbucket.org/2.0/"
|
127
133
|
when "gitlab" then "https://gitlab.com/api/v4"
|
128
134
|
when "azure" then "https://dev.azure.com/"
|
135
|
+
when "codecommit" then nil
|
129
136
|
else raise "Unexpected provider '#{provider}'"
|
130
137
|
end
|
131
138
|
end
|
data/lib/dependabot/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.113.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk-codecommit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.28'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.28'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: aws-sdk-ecr
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,20 +106,6 @@ dependencies:
|
|
92
106
|
- - "~>"
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
version: '4.9'
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: gpgme
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '2.0'
|
102
|
-
type: :runtime
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '2.0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: nokogiri
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,6 +210,20 @@ dependencies:
|
|
210
210
|
- - "~>"
|
211
211
|
- !ruby/object:Gem::Version
|
212
212
|
version: '11.0'
|
213
|
+
- !ruby/object:Gem::Dependency
|
214
|
+
name: gpgme
|
215
|
+
requirement: !ruby/object:Gem::Requirement
|
216
|
+
requirements:
|
217
|
+
- - "~>"
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
version: '2.0'
|
220
|
+
type: :development
|
221
|
+
prerelease: false
|
222
|
+
version_requirements: !ruby/object:Gem::Requirement
|
223
|
+
requirements:
|
224
|
+
- - "~>"
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: '2.0'
|
213
227
|
- !ruby/object:Gem::Dependency
|
214
228
|
name: rake
|
215
229
|
requirement: !ruby/object:Gem::Requirement
|
@@ -320,6 +334,7 @@ files:
|
|
320
334
|
- lib/dependabot/clients/azure.rb
|
321
335
|
- lib/dependabot/clients/bitbucket.rb
|
322
336
|
- lib/dependabot/clients/bitbucket_with_retries.rb
|
337
|
+
- lib/dependabot/clients/codecommit.rb
|
323
338
|
- lib/dependabot/clients/github_with_retries.rb
|
324
339
|
- lib/dependabot/clients/gitlab_with_retries.rb
|
325
340
|
- lib/dependabot/dependency.rb
|
@@ -347,6 +362,7 @@ files:
|
|
347
362
|
- lib/dependabot/pull_request_creator.rb
|
348
363
|
- lib/dependabot/pull_request_creator/azure.rb
|
349
364
|
- lib/dependabot/pull_request_creator/branch_namer.rb
|
365
|
+
- lib/dependabot/pull_request_creator/codecommit.rb
|
350
366
|
- lib/dependabot/pull_request_creator/commit_signer.rb
|
351
367
|
- lib/dependabot/pull_request_creator/github.rb
|
352
368
|
- lib/dependabot/pull_request_creator/gitlab.rb
|