dependabot-common 0.95.28 → 0.95.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64752d88cd4c2e867088c5d7ab02332a3aba8602e3bb29e90b2072be99cf5077
4
- data.tar.gz: 34f059af56773a7b3eb623fbd08c6f3d0f150d0f8090352f0e9ffd31fc47c9ba
3
+ metadata.gz: 51ab8a1d3293589fe1477093a78ed847908cf3a3dfbb6e336c761dcf3cdcdcb4
4
+ data.tar.gz: ab73df799221419d36c6e26420c2015e60d69c1b62b43b10d70a7633d436a0c3
5
5
  SHA512:
6
- metadata.gz: b8f8024905048b64104fccd3cb692ed9cd40dbf47f2bff5bfc8d9d50c311ab73fbb09398965b8935df813a87144ab4402c39f24d595bcaa635c3a9d711fa80d9
7
- data.tar.gz: 027b202885e5d8f2505f0ef8a4e81ac7872a935984cf3da99785c94755a5056e967492bdb80bc87948ef1b8bdd16b9c632a7978bd064b482d5d502159f607e2f
6
+ metadata.gz: be01459381d8a9990d03921f2952a5b2c2cac0c472b9dbaa3029f45886c083a7002625280936b21109aeff72c9340d7ec1b2a7b1e0218d70b0c4def82bff9819
7
+ data.tar.gz: 842019622a8b0c67d2a57af00bbb5df0edebeb40d0a3811200e3ae8586d625c496abafa34d8142965b6e2790983dfe90546e0cbba4399d5f82e119e8f9d8769c
@@ -32,7 +32,7 @@ module Dependabot
32
32
  @source = source
33
33
  @credentials = credentials
34
34
 
35
- @submodule_directories = {}
35
+ @linked_paths = {}
36
36
  end
37
37
 
38
38
  def repo
@@ -131,8 +131,8 @@ module Dependabot
131
131
 
132
132
  return result.call unless fetch_submodules && !retrying
133
133
 
134
- _find_submodules(path)
135
- return result.call unless _submodule_for(path)
134
+ _find_linked_dirs(path)
135
+ return result.call unless _linked_dir_for(path)
136
136
 
137
137
  retrying = true
138
138
  retry
@@ -154,17 +154,37 @@ module Dependabot
154
154
  path = path.gsub(" ", "%20")
155
155
  github_response = github_client.contents(repo, path: path, ref: commit)
156
156
 
157
- if github_response.respond_to?(:type) &&
158
- github_response.type == "submodule"
159
- @submodule_directories[path] = github_response
160
- raise Octokit::NotFound
161
- elsif github_response.respond_to?(:type)
157
+ if github_response.respond_to?(:type)
158
+ update_linked_paths(repo, path, commit, github_response)
162
159
  raise Octokit::NotFound
163
160
  end
164
161
 
165
162
  github_response.map { |f| _build_github_file_struct(f) }
166
163
  end
167
164
 
165
+ def update_linked_paths(repo, path, commit, github_response)
166
+ case github_response.type
167
+ when "submodule"
168
+ sub_source = Source.from_url(github_response.submodule_git_url)
169
+ return unless sub_source
170
+
171
+ @linked_paths[path] = {
172
+ repo: sub_source.repo,
173
+ provider: sub_source.provider,
174
+ commit: github_response.sha,
175
+ path: "/"
176
+ }
177
+ when "symlink"
178
+ updated_path = File.join(File.dirname(path), github_response.target)
179
+ @linked_paths[path] = {
180
+ repo: repo,
181
+ provider: "github",
182
+ commit: commit,
183
+ path: Pathname.new(updated_path).cleanpath.to_path
184
+ }
185
+ end
186
+ end
187
+
168
188
  def _build_github_file_struct(file)
169
189
  OpenStruct.new(
170
190
  name: file.name,
@@ -212,17 +232,19 @@ module Dependabot
212
232
  end
213
233
 
214
234
  def _full_specification_for(path, fetch_submodules:)
215
- if fetch_submodules && _submodule_for(path) &&
216
- Source.from_url(
217
- @submodule_directories[_submodule_for(path)].submodule_git_url
218
- )
219
- submodule_details = @submodule_directories[_submodule_for(path)]
220
- sub_source = Source.from_url(submodule_details.submodule_git_url)
235
+ if fetch_submodules && _linked_dir_for(path)
236
+ linked_dir_details = @linked_paths[_linked_dir_for(path)]
237
+ sub_path =
238
+ path.gsub(%r{^#{Regexp.quote(_linked_dir_for(path))}(/|$)}, "")
239
+ new_path =
240
+ Pathname.new(File.join(linked_dir_details.fetch(:path), sub_path)).
241
+ cleanpath.to_path.
242
+ gsub(%r{^/}, "")
221
243
  {
222
- repo: sub_source.repo,
223
- commit: submodule_details.sha,
224
- provider: sub_source.provider,
225
- path: path.gsub(%r{^#{Regexp.quote(_submodule_for(path))}(/|$)}, "")
244
+ repo: linked_dir_details.fetch(:repo),
245
+ commit: linked_dir_details.fetch(:commit),
246
+ provider: linked_dir_details.fetch(:provider),
247
+ path: new_path
226
248
  }
227
249
  else
228
250
  {
@@ -245,10 +267,10 @@ module Dependabot
245
267
  rescue *CLIENT_NOT_FOUND_ERRORS
246
268
  retrying ||= false
247
269
 
248
- raise unless fetch_submodules && !retrying && !_submodule_for(path)
270
+ raise unless fetch_submodules && !retrying && !_linked_dir_for(path)
249
271
 
250
- _find_submodules(path)
251
- raise unless _submodule_for(path)
272
+ _find_linked_dirs(path)
273
+ raise unless _linked_dir_for(path)
252
274
 
253
275
  retrying = true
254
276
  retry
@@ -306,10 +328,10 @@ module Dependabot
306
328
  raise Dependabot::RepoNotFound, source
307
329
  end
308
330
 
309
- # Update the @submodule_directories hash by exploiting a side-effect of
331
+ # Update the @linked_paths hash by exploiting a side-effect of
310
332
  # recursively calling `repo_contents` for each directory up the tree
311
- # until a submodule is found
312
- def _find_submodules(path)
333
+ # until a submodule or symlink is found
334
+ def _find_linked_dirs(path)
313
335
  path = Pathname.new(path).cleanpath.to_path.gsub(%r{^/*}, "")
314
336
  dir = File.dirname(path)
315
337
 
@@ -323,9 +345,9 @@ module Dependabot
323
345
  )
324
346
  end
325
347
 
326
- def _submodule_for(path)
327
- submodules = @submodule_directories.keys
328
- submodules.
348
+ def _linked_dir_for(path)
349
+ linked_dirs = @linked_paths.keys
350
+ linked_dirs.
329
351
  select { |k| path.match?(%r{^#{Regexp.quote(k)}(/|$)}) }.
330
352
  max_by(&:length)
331
353
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.95.28"
4
+ VERSION = "0.95.29"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.95.28
4
+ version: 0.95.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-14 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ecr