dependabot-common 0.120.5 → 0.123.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dependabot-common might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ab02aa6eb8de11dcba65e1e52b1dc5e83517d61d3891d40b76fcc3b5cd54db6
4
- data.tar.gz: 26a951f38732e3993fd2fc3f83c2463cf792ef51dd3a9895d8eb0b6c8abcda3d
3
+ metadata.gz: 103a0b99bbafd483f6b638fabd7aeb5276a4d59794869a42ee7e4d64381b592d
4
+ data.tar.gz: 419bfa957b475a720c7d469899f1f5ca473e15a2779534d9dc33f10b9d8dd90c
5
5
  SHA512:
6
- metadata.gz: '09593dbc78bd211b718941c2c70455823d4038647084e5d3e4b56be7f036d8126af40b8a6900ee8193f8a865790615d111489466975c099d9297c66bc09c0cb6'
7
- data.tar.gz: e1efed34b73df2126d997ec59ee92edf50fef5baa1313018aabd81b1f3c67f0cea1bc67a6b2507b24164862158e60b683b003f6df241ebde0da9797048e2f276
6
+ metadata.gz: 1385b30618626289217bebead094c165ca50bb62ff6e26d805fc52200a64e8e4b7f447cc2959a6d9aa6f863dae73a68b66a34d1f9ce82c8ab256c70c23126b72
7
+ data.tar.gz: 9d09fbff160f5301a4ea22cdcb6150dc1d87e3a01e8cc316a97ecfa629655a49e2d59b069196d5a923d1076de1992fd3dbb181bd27614835f3ebd787de9184c3
@@ -4,18 +4,19 @@ module Dependabot
4
4
  module FileUpdaters
5
5
  class Base
6
6
  attr_reader :dependencies, :dependency_files, :repo_contents_path,
7
- :credentials
7
+ :credentials, :options
8
8
 
9
9
  def self.updated_files_regex
10
10
  raise NotImplementedError
11
11
  end
12
12
 
13
13
  def initialize(dependencies:, dependency_files:, repo_contents_path: nil,
14
- credentials:)
14
+ credentials:, options: {})
15
15
  @dependencies = dependencies
16
16
  @dependency_files = dependency_files
17
17
  @repo_contents_path = repo_contents_path
18
18
  @credentials = credentials
19
+ @options = options
19
20
 
20
21
  check_required_files
21
22
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dependabot/dependency_file"
4
+
5
+ module Dependabot
6
+ module FileUpdaters
7
+ class VendorUpdater
8
+ def initialize(repo_contents_path:, vendor_dir:)
9
+ @repo_contents_path = repo_contents_path
10
+ @vendor_dir = vendor_dir
11
+ end
12
+
13
+ # Returns changed files in the vendor/cache folder
14
+ #
15
+ # @param base_directory [String] Update config base directory
16
+ # @return [Array<Dependabot::DependencyFile>]
17
+ def updated_vendor_cache_files(base_directory:)
18
+ return [] unless repo_contents_path && vendor_dir
19
+
20
+ Dir.chdir(repo_contents_path) do
21
+ relative_dir = vendor_dir.sub("#{repo_contents_path}/", "")
22
+ status = SharedHelpers.run_shell_command(
23
+ "git status --untracked-files=all --porcelain=v1 #{relative_dir}"
24
+ )
25
+ changed_paths = status.split("\n").map { |l| l.split(" ") }
26
+ changed_paths.map do |type, path|
27
+ deleted = type == "D"
28
+ encoding = ""
29
+ encoded_content = File.read(path) unless deleted
30
+ if binary_file?(path)
31
+ encoding = Dependabot::DependencyFile::ContentEncoding::BASE64
32
+ encoded_content = Base64.encode64(encoded_content) unless deleted
33
+ end
34
+ Dependabot::DependencyFile.new(
35
+ name: path,
36
+ content: encoded_content,
37
+ directory: base_directory,
38
+ deleted: deleted,
39
+ content_encoding: encoding
40
+ )
41
+ end
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ BINARY_ENCODINGS = %w(application/x-tarbinary binary).freeze
48
+
49
+ attr_reader :repo_contents_path, :vendor_dir
50
+
51
+ def binary_file?(path)
52
+ return false unless File.exist?(path)
53
+
54
+ encoding = `file -b --mime-encoding #{path}`.strip
55
+
56
+ BINARY_ENCODINGS.include?(encoding)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -57,34 +57,12 @@ module Dependabot
57
57
  end
58
58
  end
59
59
 
60
- def self.in_a_forked_process
61
- read, write = IO.pipe
62
-
63
- pid = fork do
64
- read.close
65
- result = yield
66
- rescue Exception => e # rubocop:disable Lint/RescueException
67
- result = { _error_details: { error_class: e.class.to_s,
68
- error_message: e.message,
69
- error_backtrace: e.backtrace } }
70
- ensure
71
- Marshal.dump(result, write)
72
- exit!(0)
73
- end
74
-
75
- write.close
76
- result = read.read
77
- Process.wait(pid)
78
- result = Marshal.load(result) # rubocop:disable Security/MarshalLoad
79
-
80
- return result unless result.is_a?(Hash) && result[:_error_details]
81
-
82
- raise ChildProcessFailed, result[:_error_details]
83
- end
84
-
85
60
  class HelperSubprocessFailed < StandardError
86
- def initialize(message:, error_context:)
61
+ attr_reader :error_class, :error_context
62
+
63
+ def initialize(message:, error_context:, error_class: nil)
87
64
  super(message)
65
+ @error_class = error_class || ""
88
66
  @error_context = error_context
89
67
  @command = error_context[:command]
90
68
  end
@@ -110,6 +88,11 @@ module Dependabot
110
88
  stdout, stderr, process = Open3.capture3(*env_cmd, stdin_data: stdin_data)
111
89
  time_taken = Time.now - start
112
90
 
91
+ if ENV["DEBUG_HELPERS"] == "true"
92
+ puts stdout
93
+ puts stderr
94
+ end
95
+
113
96
  # Some package managers output useful stuff to stderr instead of stdout so
114
97
  # we want to parse this, most package manager will output garbage here so
115
98
  # would mess up json response from stdout
@@ -129,11 +112,13 @@ module Dependabot
129
112
 
130
113
  raise HelperSubprocessFailed.new(
131
114
  message: response["error"],
115
+ error_class: response["error_class"],
132
116
  error_context: error_context
133
117
  )
134
118
  rescue JSON::ParserError
135
119
  raise HelperSubprocessFailed.new(
136
120
  message: stdout || "No output from command",
121
+ error_class: "JSON::ParserError",
137
122
  error_context: error_context
138
123
  )
139
124
  end
@@ -173,6 +158,9 @@ module Dependabot
173
158
  end
174
159
 
175
160
  def self.configure_git_to_use_https_with_credentials(credentials)
161
+ File.open(GIT_CONFIG_GLOBAL_PATH, "w") do |file|
162
+ file << "# Generated by dependabot/dependabot-core"
163
+ end
176
164
  configure_git_to_use_https
177
165
  configure_git_credentials(credentials)
178
166
  end
@@ -258,7 +246,10 @@ module Dependabot
258
246
  end
259
247
 
260
248
  def self.reset_global_git_config(backup_path)
261
- return if backup_path.nil?
249
+ if backup_path.nil?
250
+ FileUtils.rm(GIT_CONFIG_GLOBAL_PATH)
251
+ return
252
+ end
262
253
  return unless File.exist?(backup_path)
263
254
 
264
255
  FileUtils.mv(backup_path, GIT_CONFIG_GLOBAL_PATH)
@@ -29,5 +29,15 @@ module Dependabot
29
29
  def self.register_requirement_class(package_manager, requirement_class)
30
30
  @requirement_classes[package_manager] = requirement_class
31
31
  end
32
+
33
+ @cloning_package_managers = Set[]
34
+
35
+ def self.always_clone_for_package_manager?(package_manager)
36
+ @cloning_package_managers.include?(package_manager)
37
+ end
38
+
39
+ def self.register_always_clone(package_manager)
40
+ @cloning_package_managers << package_manager
41
+ end
32
42
  end
33
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.120.5"
4
+ VERSION = "0.123.0"
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.120.5
4
+ version: 0.123.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-codecommit
@@ -292,14 +292,42 @@ dependencies:
292
292
  requirements:
293
293
  - - "~>"
294
294
  - !ruby/object:Gem::Version
295
- version: 0.92.0
295
+ version: 0.93.0
296
296
  type: :development
297
297
  prerelease: false
298
298
  version_requirements: !ruby/object:Gem::Requirement
299
299
  requirements:
300
300
  - - "~>"
301
301
  - !ruby/object:Gem::Version
302
- version: 0.92.0
302
+ version: 0.93.0
303
+ - !ruby/object:Gem::Dependency
304
+ name: simplecov
305
+ requirement: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - "~>"
308
+ - !ruby/object:Gem::Version
309
+ version: 0.19.0
310
+ type: :development
311
+ prerelease: false
312
+ version_requirements: !ruby/object:Gem::Requirement
313
+ requirements:
314
+ - - "~>"
315
+ - !ruby/object:Gem::Version
316
+ version: 0.19.0
317
+ - !ruby/object:Gem::Dependency
318
+ name: simplecov-console
319
+ requirement: !ruby/object:Gem::Requirement
320
+ requirements:
321
+ - - "~>"
322
+ - !ruby/object:Gem::Version
323
+ version: 0.7.2
324
+ type: :development
325
+ prerelease: false
326
+ version_requirements: !ruby/object:Gem::Requirement
327
+ requirements:
328
+ - - "~>"
329
+ - !ruby/object:Gem::Version
330
+ version: 0.7.2
303
331
  - !ruby/object:Gem::Dependency
304
332
  name: vcr
305
333
  requirement: !ruby/object:Gem::Requirement
@@ -356,6 +384,7 @@ files:
356
384
  - lib/dependabot/file_updaters.rb
357
385
  - lib/dependabot/file_updaters/README.md
358
386
  - lib/dependabot/file_updaters/base.rb
387
+ - lib/dependabot/file_updaters/vendor_updater.rb
359
388
  - lib/dependabot/git_commit_checker.rb
360
389
  - lib/dependabot/git_metadata_fetcher.rb
361
390
  - lib/dependabot/metadata_finders.rb