Skip to content

Commit

Permalink
Revert "fix Gemfile not updating for peer dependencies (#7621)"
Browse files Browse the repository at this point in the history
This reverts commit 4392f1c.
  • Loading branch information
deivid-rodriguez committed Aug 3, 2023
1 parent 7c05493 commit 1df4156
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 227 deletions.
24 changes: 6 additions & 18 deletions bundler/lib/dependabot/bundler/update_checker/force_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ def original_dependencies
).parse
end

def top_level_dependencies
@top_level_dependencies ||=
FileParser.new(
dependency_files: dependency_files.reject { |file| file.name == lockfile.name },
credentials: credentials,
source: nil
).parse
end

def dependencies_from(updated_deps, specs)
# You might think we'd want to remove dependencies whose version
# hadn't changed from this array. We don't. We still need to unlock
Expand All @@ -94,17 +85,14 @@ def dependencies_from(updated_deps, specs)
#
# This is kind of a bug in Bundler, and we should try to fix it,
# but resolving it won't necessarily be easy.
updated_deps.filter_map do |dep|
original_dep =
original_dependencies.find { |d| d.name == dep.fetch("name") }
spec = specs.find { |d| d.fetch("name") == dep.fetch("name") }

# put the lead dependency first
index = specs.index { |dep| dep["name"] == updated_deps.first["name"] }
specs.unshift(specs.delete_at(index))
specs.filter_map do |dep|
next unless top_level_dependencies.find { |d| d.name == dep.fetch("name") }

original_dep = original_dependencies.find { |d| d.name == dep.fetch("name") }
next if dep.fetch("version") == original_dep.version
next if spec.fetch("version") == original_dep.version

build_dependency(original_dep, dep)
build_dependency(original_dep, spec)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,50 +215,5 @@
to raise_error(Dependabot::DependencyFileNotResolvable)
end
end

context "when peer dependencies in the Gemfile should update together" do
let(:dependency_files) { bundler_project_dependency_files("top_level_update") }
let(:target_version) { "19.4" }
let(:dependency_name) { "octicons" }
let(:requirements) do
[{
file: "Gemfile",
requirement: "~> 19.2",
groups: [:default],
source: nil
}]
end
let(:expected_requirements) do
[{
file: "Gemfile",
requirement: "~> 19.4",
groups: [:default],
source: nil
}]
end

it "updates all dependencies" do
expect(updated_dependencies).to eq(
[
Dependabot::Dependency.new(
name: "octicons",
version: "19.4.0",
previous_version: "19.2.0",
requirements: expected_requirements,
previous_requirements: requirements,
package_manager: "bundler"
),
Dependabot::Dependency.new(
name: "octicons_helper",
version: "19.4.0",
previous_version: "19.2.0",
requirements: expected_requirements,
previous_requirements: requirements,
package_manager: "bundler"
)
]
)
end
end
end
end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 1df4156

Please sign in to comment.