dependabot-go_modules 0.108.5 → 0.108.6

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: b40e73489de1680eba2f39e21a02e66a1ae741f8df455f2ae78fb7f307403654
4
- data.tar.gz: af72b097af408e66b30885e8f61e9a2f7eb4d379fb13c2a6983cc9223a70dd36
3
+ metadata.gz: ce6f5dc536a60ddf4cd51d4ccce3faf0ceb5de3f24da316263d812fe409727f3
4
+ data.tar.gz: f96dd76188542d28ad13d511eda0bc38e86fb34e75273d590aaf398bb1903362
5
5
  SHA512:
6
- metadata.gz: c62811a5de266908eea3cef1e4c519a5febd8541e6413d32bb28b4cde768dce98daee9b7d781ae60149d1d5c79544e97364c6cc8758fca56fb14a1dc211a5fde
7
- data.tar.gz: 0afef8107f8992e2b9c6f5fc2d996605444ad1ae4facda23029fb3f021229b12d2f29ad0afe6e1f9abc703cc2b04a68c50b2a136b53b6a90bbb760fd61f677b8
6
+ metadata.gz: fd77729970e9cea2f739ad73d5adf52b2e7ef60bfa135e7fdfadef9b60e2002ae8353a48310cc467bbe28a0e6c5e4d86ba8119f0f862badcd59d7679a010053c
7
+ data.tar.gz: 6db938d4567033e8997889739ea6aaa487ac83d0c090db787fa8818a968d5eb11eb9c87effeb1bf87ded6309d03c4500c4a229ebcdf6330c9e25cbbe40b540a9
@@ -17,7 +17,7 @@ module Dependabot
17
17
  dependency_set = Dependabot::FileParsers::Base::DependencySet.new
18
18
 
19
19
  i = 0
20
- chunks = module_info(go_mod).lines.
20
+ chunks = module_info.lines.
21
21
  group_by { |line| line == "{\n" ? i += 1 : i }
22
22
  deps = chunks.values.map { |chunk| JSON.parse(chunk.join) }
23
23
 
@@ -65,11 +65,19 @@ module Dependabot
65
65
  )
66
66
  end
67
67
 
68
- def module_info(go_mod)
68
+ def module_info
69
69
  @module_info ||=
70
70
  SharedHelpers.in_a_temporary_directory do |path|
71
71
  SharedHelpers.with_git_configured(credentials: credentials) do
72
- File.write("go.mod", go_mod.content)
72
+ # Create a fake empty module for each local module so that
73
+ # `go list` works, even if some modules have been `replace`d with
74
+ # a local module that we don't have access to.
75
+ local_replacements.each do |_, stub_path|
76
+ Dir.mkdir(stub_path) unless Dir.exist?(stub_path)
77
+ FileUtils.touch(File.join(stub_path, "go.mod"))
78
+ end
79
+
80
+ File.write("go.mod", go_mod_content)
73
81
 
74
82
  command = "go mod edit -print > /dev/null"
75
83
  command += " && go list -m -json all"
@@ -89,6 +97,36 @@ module Dependabot
89
97
  end
90
98
  end
91
99
 
100
+ def local_replacements
101
+ @local_replacements ||=
102
+ SharedHelpers.in_a_temporary_directory do |path|
103
+ File.write("go.mod", go_mod.content)
104
+
105
+ # Parse the go.mod to get a JSON representation of the replace
106
+ # directives
107
+ command = "go mod edit -json"
108
+ env = { "GO111MODULE" => "on" }
109
+ stdout, stderr, status = Open3.capture3(env, command)
110
+ handle_parser_error(path, stderr) unless status.success?
111
+
112
+ # Find all the local replacements, and return them with a stub path
113
+ # we can use in their place. Using generated paths is safer as it
114
+ # means we don't need to worry about references to parent
115
+ # directories, etc.
116
+ (JSON.parse(stdout)["Replace"] || []).
117
+ map { |r| r["New"]["Path"] }.
118
+ compact.
119
+ select { |p| p.start_with?(".") || p.start_with?("/") }.
120
+ map { |p| [p, "./" + Digest::SHA2.hexdigest(p)] }
121
+ end
122
+ end
123
+
124
+ def go_mod_content
125
+ local_replacements.reduce(go_mod.content) do |body, (path, stub_path)|
126
+ body.sub(path, stub_path)
127
+ end
128
+ end
129
+
92
130
  GIT_ERROR_REGEX = /go: .*: git fetch .*: exit status 128/.freeze
93
131
 
94
132
  # rubocop:disable Metrics/AbcSize
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.108.5
4
+ version: 0.108.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-06 00:00:00.000000000 Z
11
+ date: 2019-06-07 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.108.5
19
+ version: 0.108.6
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.108.5
26
+ version: 0.108.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement