dependabot-go_modules 0.121.1 → 0.122.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d399469f8a61821f96b70b4665ef9037c9c103194ae3aa7224fa7bbf45e19cc6
4
- data.tar.gz: 041406a7f88713b93f2c91b3fcf903934037975c82a8a7facebc9849baba4488
3
+ metadata.gz: 4668f28343a248c1d0e2ec3d61ffb59b79be51eb0df6ece487db719379935e3f
4
+ data.tar.gz: a5957a544166a39647cee725a66c85503887a8e141589adbfed2987a47d987b3
5
5
  SHA512:
6
- metadata.gz: df43946eea402a831d37a56637c69afe605b0c7ea3ad8e387d5e74175b13f629861b71073f7e0548b5630025089bdbc3fd8f7f8d6d00f6a9a08f9b20d96f84b9
7
- data.tar.gz: beb0a877aa9c40b20d499da92c26aa03ebfdb9737e61ca1d296bbbb02ead76ec5ab2f953b3430cb7051de9a8bc58405ee6e0ddb105fe1b43f30136850e231594
6
+ metadata.gz: ffe602aaff9f86aa15d94ebe13d5fd533e614eeb293819a6521403fc65cbff4158a0d4b1aa00aa1373e757ec47039f95d69b39e2d9ff386e9a42055e1e8283ef
7
+ data.tar.gz: 0b30b162084a264df70c145b1fecc99f9895e9c5594a08b2a90730dd8b1aa56c9bd535eeb6bc78430e140812dacca17a9e61017c1dfa76eebaf4ffef739b22d8
@@ -3,6 +3,7 @@
3
3
  require "dependabot/shared_helpers"
4
4
  require "dependabot/file_updaters"
5
5
  require "dependabot/file_updaters/base"
6
+ require "dependabot/file_updaters/vendor_updater"
6
7
 
7
8
  module Dependabot
8
9
  module GoModules
@@ -54,6 +55,12 @@ module Dependabot
54
55
  content: file_updater.updated_go_sum_content
55
56
  )
56
57
  end
58
+
59
+ vendor_updater.
60
+ updated_vendor_cache_files(base_directory: directory).
61
+ each do |file|
62
+ updated_files << file
63
+ end
57
64
  end
58
65
 
59
66
  raise "No files changed!" if updated_files.none?
@@ -81,6 +88,17 @@ module Dependabot
81
88
  dependency_files.first.directory
82
89
  end
83
90
 
91
+ def vendor_dir
92
+ File.join(repo_contents_path, directory, "vendor")
93
+ end
94
+
95
+ def vendor_updater
96
+ Dependabot::FileUpdaters::VendorUpdater.new(
97
+ repo_contents_path: repo_contents_path,
98
+ vendor_dir: vendor_dir
99
+ )
100
+ end
101
+
84
102
  def file_updater
85
103
  @file_updater ||=
86
104
  GoModUpdater.new(
@@ -88,9 +106,18 @@ module Dependabot
88
106
  credentials: credentials,
89
107
  repo_contents_path: repo_contents_path,
90
108
  directory: directory,
91
- tidy: !@repo_contents_stub && options.fetch(:go_mod_tidy, false)
109
+ options: { tidy: tidy?, vendor: vendor? }
92
110
  )
93
111
  end
112
+
113
+ def tidy?
114
+ !@repo_contents_stub && options.fetch(:go_mod_tidy, false)
115
+ end
116
+
117
+ def vendor?
118
+ File.exist?(File.join(vendor_dir, "modules.txt")) &&
119
+ options.fetch(:go_mod_vendor, false)
120
+ end
94
121
  end
95
122
  end
96
123
  end
@@ -26,12 +26,13 @@ module Dependabot
26
26
  ].freeze
27
27
 
28
28
  def initialize(dependencies:, credentials:, repo_contents_path:,
29
- directory:, tidy:)
29
+ directory:, options:)
30
30
  @dependencies = dependencies
31
31
  @credentials = credentials
32
32
  @repo_contents_path = repo_contents_path
33
33
  @directory = directory
34
- @tidy = tidy
34
+ @tidy = options.fetch(:tidy, false)
35
+ @vendor = options.fetch(:vendor, false)
35
36
  end
36
37
 
37
38
  def updated_go_mod_content
@@ -51,7 +52,7 @@ module Dependabot
51
52
  @updated_files ||= update_files
52
53
  end
53
54
 
54
- def update_files
55
+ def update_files # rubocop:disable Metrics/AbcSize
55
56
  in_repo_path do
56
57
  # Map paths in local replace directives to path hashes
57
58
 
@@ -71,6 +72,7 @@ module Dependabot
71
72
  # Then run `go get` to pick up other changes to the file caused by
72
73
  # the upgrade
73
74
  run_go_get
75
+ run_go_vendor
74
76
  run_go_mod_tidy
75
77
 
76
78
  # At this point, the go.mod returned from run_go_get contains the
@@ -111,6 +113,14 @@ module Dependabot
111
113
  handle_subprocess_error(stderr) unless status.success?
112
114
  end
113
115
 
116
+ def run_go_vendor
117
+ return unless vendor?
118
+
119
+ command = "go mod vendor"
120
+ _, stderr, status = Open3.capture3(ENVIRONMENT, command)
121
+ handle_subprocess_error(stderr) unless status.success?
122
+ end
123
+
114
124
  def update_go_mod(dependencies)
115
125
  deps = dependencies.map do |dep|
116
126
  {
@@ -273,6 +283,10 @@ module Dependabot
273
283
  def tidy?
274
284
  !!@tidy
275
285
  end
286
+
287
+ def vendor?
288
+ !!@vendor
289
+ end
276
290
  end
277
291
  end
278
292
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-go_modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.121.1
4
+ version: 0.122.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.121.1
19
+ version: 0.122.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.121.1
26
+ version: 0.122.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.92.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.19.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.19.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov-console
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.7.2
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.7.2
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: vcr
113
141
  requirement: !ruby/object:Gem::Requirement