dependabot-go_modules 0.345.0 → 0.346.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 +4 -4
- data/lib/dependabot/go_modules/dependency_grapher.rb +14 -16
- data/lib/dependabot/go_modules/file_parser.rb +10 -5
- data/lib/dependabot/go_modules/file_updater/go_mod_updater.rb +1 -1
- data/lib/dependabot/go_modules/file_updater.rb +5 -27
- data/lib/dependabot/go_modules/replace_stubber.rb +2 -3
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4b67c25a333a01db10a2f22122678237420549e40d2be2369f4472d7ba595e5
|
|
4
|
+
data.tar.gz: 32c54e5e8e1faba16f42dbb6b4c8e3118acbba53e67a0cae3ed0e540b64a22ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 96c1173e5b31b812429a2392258aea93892c99b15e876dd97df1dd42f95416f37b49fc6bc01bb50f4eb60ff1219cdd0271e8f729954b63bc77aa9f05bee7f0cf
|
|
7
|
+
data.tar.gz: 581dc00ba064553b5e97331aa15559bb4636fc9c168f7fbb96526162f785deb23d3d5ba1ad8704e1bc71913613e76b140f54524e80150a1fef4e317fe46e9fff
|
|
@@ -45,7 +45,7 @@ module Dependabot
|
|
|
45
45
|
return @go_mod if defined?(@go_mod)
|
|
46
46
|
|
|
47
47
|
@go_mod = T.let(
|
|
48
|
-
dependency_files.find { |f| f.name
|
|
48
|
+
dependency_files.find { |f| f.name == "go.mod" },
|
|
49
49
|
T.nilable(Dependabot::DependencyFile)
|
|
50
50
|
)
|
|
51
51
|
end
|
|
@@ -75,21 +75,19 @@ module Dependabot
|
|
|
75
75
|
# TODO: Re-instate method once we consider how we are handling `replace` directives
|
|
76
76
|
sig { returns(T::Hash[String, T.untyped]) }
|
|
77
77
|
def fetch_package_relationships
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# rels[match[:parent]] << match[:child]
|
|
92
|
-
# end
|
|
78
|
+
T.cast(
|
|
79
|
+
file_parser,
|
|
80
|
+
Dependabot::GoModules::FileParser
|
|
81
|
+
).run_in_parsed_context("go mod graph").lines.each_with_object({}) do |line, rels|
|
|
82
|
+
match = line.match(GO_MOD_GRAPH_LINE_REGEX)
|
|
83
|
+
unless match
|
|
84
|
+
Dependabot.logger.warn("Unexpected output from 'go mod graph': 'line'")
|
|
85
|
+
next
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
rels[match[:parent]] ||= []
|
|
89
|
+
rels[match[:parent]] << match[:child]
|
|
90
|
+
end
|
|
93
91
|
end
|
|
94
92
|
end
|
|
95
93
|
end
|
|
@@ -20,6 +20,9 @@ module Dependabot
|
|
|
20
20
|
class FileParser < Dependabot::FileParsers::Base
|
|
21
21
|
extend T::Sig
|
|
22
22
|
|
|
23
|
+
# NOTE: repo_contents_path is typed as T.nilable(String) to maintain
|
|
24
|
+
# compatibility with the base FileParser class signature. However,
|
|
25
|
+
# we validate it's not nil at runtime since it's always required in production.
|
|
23
26
|
sig do
|
|
24
27
|
params(
|
|
25
28
|
dependency_files: T::Array[Dependabot::DependencyFile],
|
|
@@ -40,6 +43,8 @@ module Dependabot
|
|
|
40
43
|
)
|
|
41
44
|
super
|
|
42
45
|
|
|
46
|
+
raise ArgumentError, "repo_contents_path is required" if repo_contents_path.nil?
|
|
47
|
+
|
|
43
48
|
set_go_environment_variables
|
|
44
49
|
end
|
|
45
50
|
|
|
@@ -75,16 +80,16 @@ module Dependabot
|
|
|
75
80
|
# Utility method to allow collaborators to check other go commands inside the parsed project's context
|
|
76
81
|
sig { params(command: String).returns(String) }
|
|
77
82
|
def run_in_parsed_context(command)
|
|
78
|
-
SharedHelpers.
|
|
79
|
-
# Create a fake empty module for
|
|
80
|
-
#
|
|
81
|
-
# a local module that we don't have access to.
|
|
83
|
+
SharedHelpers.in_a_temporary_repo_directory(T.must(source&.directory), repo_contents_path) do |path|
|
|
84
|
+
# Create a fake empty module for local modules that are not inside the repository.
|
|
85
|
+
# This allows us to run go commands that require all modules to be present.
|
|
82
86
|
local_replacements.each do |_, stub_path|
|
|
83
87
|
FileUtils.mkdir_p(stub_path)
|
|
84
88
|
FileUtils.touch(File.join(stub_path, "go.mod"))
|
|
85
89
|
end
|
|
86
90
|
|
|
87
91
|
File.write("go.mod", go_mod_content)
|
|
92
|
+
|
|
88
93
|
stdout, stderr, status = Open3.capture3(command)
|
|
89
94
|
handle_parser_error(path, stderr) unless status.success?
|
|
90
95
|
|
|
@@ -227,7 +232,7 @@ module Dependabot
|
|
|
227
232
|
# means we don't need to worry about references to parent
|
|
228
233
|
# directories, etc.
|
|
229
234
|
T.let(
|
|
230
|
-
ReplaceStubber.new(repo_contents_path).stub_paths(manifest, go_mod&.directory),
|
|
235
|
+
ReplaceStubber.new(T.must(repo_contents_path)).stub_paths(manifest, go_mod&.directory),
|
|
231
236
|
T.nilable(T::Hash[String, String])
|
|
232
237
|
)
|
|
233
238
|
end
|
|
@@ -305,7 +305,7 @@ module Dependabot
|
|
|
305
305
|
def replace_directive_substitutions(manifest)
|
|
306
306
|
@replace_directive_substitutions ||=
|
|
307
307
|
T.let(
|
|
308
|
-
Dependabot::GoModules::ReplaceStubber.new(repo_contents_path)
|
|
308
|
+
Dependabot::GoModules::ReplaceStubber.new(T.must(repo_contents_path))
|
|
309
309
|
.stub_paths(manifest, directory),
|
|
310
310
|
T.nilable(T::Hash[String, String])
|
|
311
311
|
)
|
|
@@ -15,6 +15,9 @@ module Dependabot
|
|
|
15
15
|
|
|
16
16
|
require_relative "file_updater/go_mod_updater"
|
|
17
17
|
|
|
18
|
+
# NOTE: repo_contents_path is typed as T.nilable(String) to maintain
|
|
19
|
+
# compatibility with the base FileUpdater class signature. However,
|
|
20
|
+
# we validate it's not nil at runtime since it's always required in production.
|
|
18
21
|
sig do
|
|
19
22
|
override
|
|
20
23
|
.params(
|
|
@@ -29,7 +32,7 @@ module Dependabot
|
|
|
29
32
|
def initialize(dependencies:, dependency_files:, credentials:, repo_contents_path: nil, options: {})
|
|
30
33
|
super
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
raise ArgumentError, "repo_contents_path is required" if repo_contents_path.nil?
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
sig { override.returns(T::Array[Dependabot::DependencyFile]) }
|
|
@@ -77,31 +80,6 @@ module Dependabot
|
|
|
77
80
|
raise "No go.mod!"
|
|
78
81
|
end
|
|
79
82
|
|
|
80
|
-
sig { returns(String) }
|
|
81
|
-
def use_repo_contents_stub
|
|
82
|
-
@repo_contents_stub = T.let(true, T.nilable(T::Boolean))
|
|
83
|
-
@repo_contents_path = Dir.mktmpdir
|
|
84
|
-
|
|
85
|
-
Dir.chdir(@repo_contents_path) do
|
|
86
|
-
dependency_files.each do |file|
|
|
87
|
-
path = File.join(@repo_contents_path, directory, file.name)
|
|
88
|
-
path = Pathname.new(path).expand_path
|
|
89
|
-
FileUtils.mkdir_p(path.dirname)
|
|
90
|
-
File.write(path, file.content)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Only used to create a backup git config that's reset
|
|
94
|
-
SharedHelpers.with_git_configured(credentials: []) do
|
|
95
|
-
`git config --global user.email "no-reply@github.com"`
|
|
96
|
-
`git config --global user.name "Dependabot"`
|
|
97
|
-
`git config --global init.defaultBranch "placeholder-default-branch"`
|
|
98
|
-
`git init .`
|
|
99
|
-
`git add .`
|
|
100
|
-
`git commit -m'fake repo_contents_path'`
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
83
|
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
106
84
|
def go_mod
|
|
107
85
|
@go_mod ||= T.let(get_original_file("go.mod"), T.nilable(Dependabot::DependencyFile))
|
|
@@ -147,7 +125,7 @@ module Dependabot
|
|
|
147
125
|
|
|
148
126
|
sig { returns(T::Boolean) }
|
|
149
127
|
def tidy?
|
|
150
|
-
|
|
128
|
+
true
|
|
151
129
|
end
|
|
152
130
|
|
|
153
131
|
sig { returns(T::Boolean) }
|
|
@@ -16,9 +16,9 @@ module Dependabot
|
|
|
16
16
|
class ReplaceStubber
|
|
17
17
|
extend T::Sig
|
|
18
18
|
|
|
19
|
-
sig { params(repo_contents_path:
|
|
19
|
+
sig { params(repo_contents_path: String).void }
|
|
20
20
|
def initialize(repo_contents_path)
|
|
21
|
-
@repo_contents_path = repo_contents_path
|
|
21
|
+
@repo_contents_path = T.let(repo_contents_path, String)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
sig do
|
|
@@ -37,7 +37,6 @@ module Dependabot
|
|
|
37
37
|
def stub_replace_path?(path, directory)
|
|
38
38
|
return true if absolute_path?(path)
|
|
39
39
|
return false unless relative_replacement_path?(path)
|
|
40
|
-
return true if @repo_contents_path.nil?
|
|
41
40
|
|
|
42
41
|
resolved_path = module_pathname(directory).join(path).realpath
|
|
43
42
|
inside_repo_contents_path = resolved_path.to_s.start_with?(@repo_contents_path.to_s)
|
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.
|
|
4
|
+
version: 0.346.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.346.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.346.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: debug
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -272,7 +272,7 @@ licenses:
|
|
|
272
272
|
- MIT
|
|
273
273
|
metadata:
|
|
274
274
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
275
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
275
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.346.0
|
|
276
276
|
rdoc_options: []
|
|
277
277
|
require_paths:
|
|
278
278
|
- lib
|