dependabot-bundler 0.138.2 → 0.138.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/v1/build +2 -1
- data/helpers/v1/run.rb +14 -0
- data/helpers/v2/build +2 -1
- data/helpers/v2/lib/functions.rb +8 -1
- data/helpers/v2/lib/functions/conflicting_dependency_resolver.rb +86 -0
- data/helpers/v2/run.rb +14 -0
- data/helpers/v2/spec/functions/conflicting_dependency_resolver_spec.rb +133 -0
- data/helpers/v2/spec/functions_spec.rb +0 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fe43d8a687e3405df9f2704529fe54f9e79cdb75b6246d43a32e32e5a7b1928
|
4
|
+
data.tar.gz: 67b1b3afd35f559613e57f6ef2a26ef9ee0c50910072b40c5d9ac412b830ed91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55bd706fffed2c9caa866237eea57fde3f91a83f465014865dacf2252094ad31e9098d0894c9b85da77f08e5ae0941f8a74ca1f1cfecec447775aa20541bcfae
|
7
|
+
data.tar.gz: 563832a40283d4c9f29175b0cddc850ac88e461e65905e255f94234aee9c913690525016a2d12cbfdedb17f4d5c0873214863b324207277bbfc80bccee7c7f8f
|
data/helpers/v1/build
CHANGED
@@ -21,4 +21,5 @@ cd "$install_dir"
|
|
21
21
|
|
22
22
|
# NOTE: Sets `BUNDLED WITH` to match the installed v1 version in Gemfile.lock
|
23
23
|
# forcing native helpers to run with the same version
|
24
|
-
BUNDLER_VERSION=1 bundle
|
24
|
+
BUNDLER_VERSION=1 bundle config set --local without "test"
|
25
|
+
BUNDLER_VERSION=1 bundle install
|
data/helpers/v1/run.rb
CHANGED
@@ -11,11 +11,25 @@ require "git_source_patch"
|
|
11
11
|
|
12
12
|
require "functions"
|
13
13
|
|
14
|
+
MAX_BUNDLER_VERSION="2.0.0"
|
15
|
+
|
16
|
+
def validate_bundler_version!
|
17
|
+
return true if correct_bundler_version?
|
18
|
+
|
19
|
+
raise StandardError, "Called with Bundler '#{Bundler::VERSION}', expected < '#{MAX_BUNDLER_VERSION}'"
|
20
|
+
end
|
21
|
+
|
22
|
+
def correct_bundler_version?
|
23
|
+
Gem::Version.new(Bundler::VERSION) < Gem::Version.new(MAX_BUNDLER_VERSION)
|
24
|
+
end
|
25
|
+
|
14
26
|
def output(obj)
|
15
27
|
print JSON.dump(obj)
|
16
28
|
end
|
17
29
|
|
18
30
|
begin
|
31
|
+
validate_bundler_version!
|
32
|
+
|
19
33
|
request = JSON.parse($stdin.read)
|
20
34
|
|
21
35
|
function = request["function"]
|
data/helpers/v2/build
CHANGED
@@ -20,4 +20,5 @@ cd "$install_dir"
|
|
20
20
|
# NOTE: Sets `BUNDLED WITH` to match the installed v1 version in Gemfile.lock
|
21
21
|
# forcing specs and native helpers to run with the same version
|
22
22
|
BUNDLER_VERSION=2 bundle config set --local path ".bundle"
|
23
|
-
BUNDLER_VERSION=2 bundle
|
23
|
+
BUNDLER_VERSION=2 bundle config set --local without "test"
|
24
|
+
BUNDLER_VERSION=2 bundle install
|
data/helpers/v2/lib/functions.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "functions/file_parser"
|
2
|
+
require "functions/conflicting_dependency_resolver"
|
2
3
|
|
3
4
|
module Functions
|
4
5
|
class NotImplementedError < StandardError; end
|
@@ -110,6 +111,12 @@ module Functions
|
|
110
111
|
|
111
112
|
def self.conflicting_dependencies(dir:, dependency_name:, target_version:,
|
112
113
|
lockfile_name:, using_bundler2:, credentials:)
|
113
|
-
|
114
|
+
set_bundler_flags_and_credentials(dir: dir, credentials: credentials,
|
115
|
+
using_bundler2: using_bundler2)
|
116
|
+
ConflictingDependencyResolver.new(
|
117
|
+
dependency_name: dependency_name,
|
118
|
+
target_version: target_version,
|
119
|
+
lockfile_name: lockfile_name
|
120
|
+
).conflicting_dependencies
|
114
121
|
end
|
115
122
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Functions
|
4
|
+
class ConflictingDependencyResolver
|
5
|
+
def initialize(dependency_name:, target_version:, lockfile_name:)
|
6
|
+
@dependency_name = dependency_name
|
7
|
+
@target_version = target_version
|
8
|
+
@lockfile_name = lockfile_name
|
9
|
+
end
|
10
|
+
|
11
|
+
# Finds any dependencies in the lockfile that have a subdependency on the
|
12
|
+
# given dependency that does not satisfly the target_version.
|
13
|
+
# @return [Array<Hash{String => String}]
|
14
|
+
# * explanation [String] a sentence explaining the conflict
|
15
|
+
# * name [String] the blocking dependencies name
|
16
|
+
# * version [String] the version of the blocking dependency
|
17
|
+
# * requirement [String] the requirement on the target_dependency
|
18
|
+
def conflicting_dependencies
|
19
|
+
Bundler.settings.set_command_option("only_update_to_newer_versions", true)
|
20
|
+
|
21
|
+
parent_specs.flat_map do |parent_spec|
|
22
|
+
top_level_specs_for(parent_spec).map do |top_level|
|
23
|
+
dependency = parent_spec.dependencies.find { |bd| bd.name == dependency_name }
|
24
|
+
{
|
25
|
+
"explanation" => explanation(parent_spec, dependency, top_level),
|
26
|
+
"name" => parent_spec.name,
|
27
|
+
"version" => parent_spec.version.to_s,
|
28
|
+
"requirement" => dependency.requirement.to_s
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :dependency_name, :target_version, :lockfile_name
|
37
|
+
|
38
|
+
def parent_specs
|
39
|
+
version = Gem::Version.new(target_version)
|
40
|
+
parsed_lockfile.specs.filter do |spec|
|
41
|
+
spec.dependencies.any? do |dep|
|
42
|
+
dep.name == dependency_name &&
|
43
|
+
!dep.requirement.satisfied_by?(version)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def top_level_specs_for(parent_spec)
|
49
|
+
return [parent_spec] if top_level?(parent_spec)
|
50
|
+
|
51
|
+
parsed_lockfile.specs.filter do |spec|
|
52
|
+
spec.dependencies.any? do |dep|
|
53
|
+
dep.name == parent_spec.name && top_level?(spec)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def top_level?(spec)
|
59
|
+
parsed_lockfile.dependencies.key?(spec.name)
|
60
|
+
end
|
61
|
+
|
62
|
+
def explanation(spec, dependency, top_level)
|
63
|
+
if spec.name == top_level.name
|
64
|
+
"#{spec.name} (#{spec.version}) requires #{dependency_name} (#{dependency.requirement})"
|
65
|
+
else
|
66
|
+
"#{top_level.name} (#{top_level.version}) requires #{dependency_name} "\
|
67
|
+
"(#{dependency.requirement}) via #{spec.name} (#{spec.version})"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def parsed_lockfile
|
72
|
+
@parsed_lockfile ||= Bundler::LockfileParser.new(lockfile)
|
73
|
+
end
|
74
|
+
|
75
|
+
def lockfile
|
76
|
+
return @lockfile if defined?(@lockfile)
|
77
|
+
|
78
|
+
@lockfile =
|
79
|
+
begin
|
80
|
+
return unless lockfile_name && File.exist?(lockfile_name)
|
81
|
+
|
82
|
+
File.read(lockfile_name)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/helpers/v2/run.rb
CHANGED
@@ -11,11 +11,25 @@ require "git_source_patch"
|
|
11
11
|
|
12
12
|
require "functions"
|
13
13
|
|
14
|
+
MIN_BUNDLER_VERSION = "2.0.0"
|
15
|
+
|
16
|
+
def validate_bundler_version!
|
17
|
+
return true if correct_bundler_version?
|
18
|
+
|
19
|
+
raise StandardError, "Called with Bundler '#{Bundler::VERSION}', expected >= '#{MIN_BUNDLER_VERSION}'"
|
20
|
+
end
|
21
|
+
|
22
|
+
def correct_bundler_version?
|
23
|
+
Gem::Version.new(Bundler::VERSION) >= Gem::Version.new(MIN_BUNDLER_VERSION)
|
24
|
+
end
|
25
|
+
|
14
26
|
def output(obj)
|
15
27
|
print JSON.dump(obj)
|
16
28
|
end
|
17
29
|
|
18
30
|
begin
|
31
|
+
validate_bundler_version!
|
32
|
+
|
19
33
|
request = JSON.parse($stdin.read)
|
20
34
|
|
21
35
|
function = request["function"]
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "native_spec_helper"
|
4
|
+
require "shared_contexts"
|
5
|
+
|
6
|
+
RSpec.describe Functions::ConflictingDependencyResolver do
|
7
|
+
include_context "in a temporary bundler directory"
|
8
|
+
|
9
|
+
let(:conflicting_dependency_resolver) do
|
10
|
+
described_class.new(
|
11
|
+
dependency_name: dependency_name,
|
12
|
+
target_version: target_version,
|
13
|
+
lockfile_name: "Gemfile.lock"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:dependency_name) { "dummy-pkg-a" }
|
18
|
+
let(:target_version) { "2.0.0" }
|
19
|
+
|
20
|
+
let(:project_name) { "blocked_by_subdep" }
|
21
|
+
|
22
|
+
describe "#conflicting_dependencies" do
|
23
|
+
subject(:conflicting_dependencies) do
|
24
|
+
in_tmp_folder { conflicting_dependency_resolver.conflicting_dependencies }
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns a list of dependencies that block the update" do
|
28
|
+
expect(conflicting_dependencies).to eq(
|
29
|
+
[{
|
30
|
+
"explanation" => "dummy-pkg-b (1.0.0) requires dummy-pkg-a (< 2.0.0)",
|
31
|
+
"name" => "dummy-pkg-b",
|
32
|
+
"version" => "1.0.0",
|
33
|
+
"requirement" => "< 2.0.0"
|
34
|
+
}]
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
context "for nested transitive dependencies" do
|
39
|
+
let(:project_name) { "transitive_blocking" }
|
40
|
+
let(:dependency_name) { "activesupport" }
|
41
|
+
let(:target_version) { "6.0.0" }
|
42
|
+
|
43
|
+
it "returns a list of dependencies that block the update" do
|
44
|
+
expect(conflicting_dependencies).to match_array(
|
45
|
+
[
|
46
|
+
{
|
47
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0)",
|
48
|
+
"name" => "rails",
|
49
|
+
"requirement" => "= 5.2.0",
|
50
|
+
"version" => "5.2.0"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0) via actionpack (5.2.0)",
|
54
|
+
"name" => "actionpack",
|
55
|
+
"version" => "5.2.0",
|
56
|
+
"requirement" => "= 5.2.0"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0) via actionview (5.2.0)",
|
60
|
+
"name" => "actionview",
|
61
|
+
"version" => "5.2.0",
|
62
|
+
"requirement" => "= 5.2.0"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0) via activejob (5.2.0)",
|
66
|
+
"name" => "activejob",
|
67
|
+
"version" => "5.2.0",
|
68
|
+
"requirement" => "= 5.2.0"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0) via activemodel (5.2.0)",
|
72
|
+
"name" => "activemodel",
|
73
|
+
"version" => "5.2.0",
|
74
|
+
"requirement" => "= 5.2.0"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0) via activerecord (5.2.0)",
|
78
|
+
"name" => "activerecord",
|
79
|
+
"version" => "5.2.0",
|
80
|
+
"requirement" => "= 5.2.0"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"explanation" => "rails (5.2.0) requires activesupport (= 5.2.0) via railties (5.2.0)",
|
84
|
+
"name" => "railties",
|
85
|
+
"version" => "5.2.0",
|
86
|
+
"requirement" => "= 5.2.0"
|
87
|
+
}
|
88
|
+
]
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with multiple blocking dependencies" do
|
94
|
+
let(:dependency_name) { "activesupport" }
|
95
|
+
let(:current_version) { "5.0.0" }
|
96
|
+
let(:target_version) { "6.0.0" }
|
97
|
+
let(:project_name) { "multiple_blocking" }
|
98
|
+
|
99
|
+
it "returns all of the blocking dependencies" do
|
100
|
+
expect(conflicting_dependencies).to match_array(
|
101
|
+
[
|
102
|
+
{
|
103
|
+
"explanation" => "actionmailer (5.0.0) requires activesupport (= 5.0.0) via actionpack (5.0.0)",
|
104
|
+
"name" => "actionpack",
|
105
|
+
"version" => "5.0.0",
|
106
|
+
"requirement" => "= 5.0.0"
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"explanation" => "actionview (5.0.0) requires activesupport (= 5.0.0)",
|
110
|
+
"name" => "actionview",
|
111
|
+
"version" => "5.0.0",
|
112
|
+
"requirement" => "= 5.0.0"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"explanation" => "actionmailer (5.0.0) requires activesupport (= 5.0.0) via activejob (5.0.0)",
|
116
|
+
"name" => "activejob",
|
117
|
+
"version" => "5.0.0",
|
118
|
+
"requirement" => "= 5.0.0"
|
119
|
+
}
|
120
|
+
]
|
121
|
+
)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "without any blocking dependencies" do
|
126
|
+
let(:target_version) { "1.0.0" }
|
127
|
+
|
128
|
+
it "returns an empty list" do
|
129
|
+
expect(conflicting_dependencies).to eq([])
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -17,7 +17,6 @@ RSpec.describe Functions do
|
|
17
17
|
:dir, :credentials],
|
18
18
|
jfrog_source: [:dir, :gemfile_name, :credentials, :using_bundler2],
|
19
19
|
git_specs: [:dir, :gemfile_name, :credentials, :using_bundler2],
|
20
|
-
conflicting_dependencies: [:dir, :dependency_name, :target_version, :lockfile_name, :using_bundler2, :credentials]
|
21
20
|
}.each do |function, kwargs|
|
22
21
|
describe "::#{function}" do
|
23
22
|
let(:args) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-bundler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.138.
|
4
|
+
version: 0.138.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-24 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.138.
|
19
|
+
version: 0.138.3
|
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.138.
|
26
|
+
version: 0.138.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,11 +210,13 @@ files:
|
|
210
210
|
- helpers/v2/Gemfile
|
211
211
|
- helpers/v2/build
|
212
212
|
- helpers/v2/lib/functions.rb
|
213
|
+
- helpers/v2/lib/functions/conflicting_dependency_resolver.rb
|
213
214
|
- helpers/v2/lib/functions/file_parser.rb
|
214
215
|
- helpers/v2/monkey_patches/definition_bundler_version_patch.rb
|
215
216
|
- helpers/v2/monkey_patches/definition_ruby_version_patch.rb
|
216
217
|
- helpers/v2/monkey_patches/git_source_patch.rb
|
217
218
|
- helpers/v2/run.rb
|
219
|
+
- helpers/v2/spec/functions/conflicting_dependency_resolver_spec.rb
|
218
220
|
- helpers/v2/spec/functions/file_parser_spec.rb
|
219
221
|
- helpers/v2/spec/functions_spec.rb
|
220
222
|
- helpers/v2/spec/native_spec_helper.rb
|