dependabot-go_modules 0.121.0 → 0.123.1

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: 701e98b35df513747baf443e0438108b3b9654e27f34f8c2222a6a66ca2ed629
4
- data.tar.gz: 9a072a70eff30b0958a11ea3c18a52a9d226f0638802cac4c1a11ce43c11179e
3
+ metadata.gz: 8d87f9480f3afc9e6bdef144aa05c69503d9ce3f6ba77874312f1154a45acc5f
4
+ data.tar.gz: 4efcae643e50fe122f811ac929ec57b851eddd7dba0a6bf2f25cc1bf8314357c
5
5
  SHA512:
6
- metadata.gz: f4c5afb8286faed93d541b40f466baa9ccf3204b3ba7ef600658b202dc30ec3085f8ac22a81169372a92d3edbbe4232ba2018c69824394d81db57cae44108f56
7
- data.tar.gz: 3637c5c1b624bfba9e3b4a4af263e2aff7411c5ff181ae9c35cf1edc34b11fe62206dce9b3917dcc3869f78f76030158f43747fe0205becb969d3593a7ce1216
6
+ metadata.gz: 42a2f3835e2a99b515dfc875414244a9ed6f867cde47669d907d4bf27c2e5a4fc98c97a733d23aa0ec69e789e6f6f723f9af66740e949ef4633bcbe3ae3735e3
7
+ data.tar.gz: b5ba80c87a48e95e713d7d7c3cad2a6d5616398eda50aaf5ae938909be21a3a58ff1629fd2ead7e4f5139f36277e048b72421d18ab5c8d951cc6a5e551b005f0
@@ -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
@@ -20,6 +21,8 @@ module Dependabot
20
21
  dependency_files.each do |file|
21
22
  File.write(file.name, file.content)
22
23
  end
24
+ `git config --global user.email "no-reply@github.com"`
25
+ `git config --global user.name "Dependabot"`
23
26
  `git init .`
24
27
  `git add .`
25
28
  `git commit -m'fake repo_contents_path'`
@@ -52,6 +55,12 @@ module Dependabot
52
55
  content: file_updater.updated_go_sum_content
53
56
  )
54
57
  end
58
+
59
+ vendor_updater.
60
+ updated_vendor_cache_files(base_directory: directory).
61
+ each do |file|
62
+ updated_files << file
63
+ end
55
64
  end
56
65
 
57
66
  raise "No files changed!" if updated_files.none?
@@ -79,6 +88,17 @@ module Dependabot
79
88
  dependency_files.first.directory
80
89
  end
81
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
+
82
102
  def file_updater
83
103
  @file_updater ||=
84
104
  GoModUpdater.new(
@@ -86,9 +106,18 @@ module Dependabot
86
106
  credentials: credentials,
87
107
  repo_contents_path: repo_contents_path,
88
108
  directory: directory,
89
- tidy: !@repo_contents_stub && options.fetch(:go_mod_tidy, false)
109
+ options: { tidy: tidy?, vendor: vendor? }
90
110
  )
91
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
92
121
  end
93
122
  end
94
123
  end
@@ -14,9 +14,14 @@ module Dependabot
14
14
  ENVIRONMENT = { "GOPRIVATE" => "*" }.freeze
15
15
 
16
16
  RESOLVABILITY_ERROR_REGEXES = [
17
+ # (Private) module could not be fetched
17
18
  /go: .*: git fetch .*: exit status 128/.freeze,
19
+ # The checksum in go.sum does not match the dowloaded content
18
20
  /verifying .*: checksum mismatch/.freeze,
19
- /build .*: cannot find module providing package/.freeze
21
+ # (Private) module could not be found
22
+ /cannot find module providing package/.freeze,
23
+ # Package in module was likely renamed or removed
24
+ /module .* found \(.*\), but does not contain package/m.freeze
20
25
  ].freeze
21
26
 
22
27
  MODULE_PATH_MISMATCH_REGEXES = [
@@ -26,12 +31,13 @@ module Dependabot
26
31
  ].freeze
27
32
 
28
33
  def initialize(dependencies:, credentials:, repo_contents_path:,
29
- directory:, tidy:)
34
+ directory:, options:)
30
35
  @dependencies = dependencies
31
36
  @credentials = credentials
32
37
  @repo_contents_path = repo_contents_path
33
38
  @directory = directory
34
- @tidy = tidy
39
+ @tidy = options.fetch(:tidy, false)
40
+ @vendor = options.fetch(:vendor, false)
35
41
  end
36
42
 
37
43
  def updated_go_mod_content
@@ -51,7 +57,7 @@ module Dependabot
51
57
  @updated_files ||= update_files
52
58
  end
53
59
 
54
- def update_files
60
+ def update_files # rubocop:disable Metrics/AbcSize
55
61
  in_repo_path do
56
62
  # Map paths in local replace directives to path hashes
57
63
 
@@ -71,6 +77,7 @@ module Dependabot
71
77
  # Then run `go get` to pick up other changes to the file caused by
72
78
  # the upgrade
73
79
  run_go_get
80
+ run_go_vendor
74
81
  run_go_mod_tidy
75
82
 
76
83
  # At this point, the go.mod returned from run_go_get contains the
@@ -111,6 +118,14 @@ module Dependabot
111
118
  handle_subprocess_error(stderr) unless status.success?
112
119
  end
113
120
 
121
+ def run_go_vendor
122
+ return unless vendor?
123
+
124
+ command = "go mod vendor"
125
+ _, stderr, status = Open3.capture3(ENVIRONMENT, command)
126
+ handle_subprocess_error(stderr) unless status.success?
127
+ end
128
+
114
129
  def update_go_mod(dependencies)
115
130
  deps = dependencies.map do |dep|
116
131
  {
@@ -273,6 +288,10 @@ module Dependabot
273
288
  def tidy?
274
289
  !!@tidy
275
290
  end
291
+
292
+ def vendor?
293
+ !!@vendor
294
+ end
276
295
  end
277
296
  end
278
297
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-go_modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.121.0
4
+ version: 0.123.1
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-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.121.0
19
+ version: 0.123.1
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.0
26
+ version: 0.123.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,42 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.92.0
103
+ version: 0.93.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.92.0
110
+ version: 0.93.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