Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pub] use 'increase-if-necessary' as the default strategy for pub dependencies #6786

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions pub/lib/dependabot/pub/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,8 @@ def resolve_requirements_update_strategy
[nil, "widen_ranges", "bump_versions", "bump_versions_if_necessary"].include? requirements_update_strategy

if requirements_update_strategy.nil?
# Check for a version field in the pubspec.yaml. If it is present
# we assume the package is a library, and the requirement update
# strategy is widening. Otherwise we assume it is an application, and
# go for "bump_versions".
pubspec = dependency_files.find { |d| d.name == "pubspec.yaml" }
begin
parsed_pubspec = YAML.safe_load(pubspec.content, aliases: false)
rescue ScriptError
return "bump_versions"
end
if parsed_pubspec["version"].nil? || parsed_pubspec["publish_to"] == "none"
"bump_versions"
else
"widen_ranges"
end
# If no explicit strategy is given, default to 'increase-if-necessary' (#4979).
"bump_versions_if_necessary"
else
requirements_update_strategy
end
Expand Down
40 changes: 2 additions & 38 deletions pub/spec/dependabot/pub/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}],
"previous_version" => "1.14.13",
"requirements" => [{
file: "pubspec.yaml", groups: ["direct"], requirement: "^1.16.0", source: nil
file: "pubspec.yaml", groups: ["direct"], requirement: "^1.14.13", source: nil
}],
"version" => "1.16.0" }
]
Expand All @@ -142,7 +142,7 @@
# Dependabot lifts this from the original dependency.
"previous_version" => "0.0.0",
"requirements" => [{
file: "pubspec.yaml", groups: ["direct"], requirement: "^1.16.0", source: nil
file: "pubspec.yaml", groups: ["direct"], requirement: "^1.14.13", source: nil
}],
"version" => "1.16.0" }
]
Expand Down Expand Up @@ -269,42 +269,6 @@
]
end
end
context "app (version but publish_to: none)" do
let(:project) { "can_update_publish_to_none" }
it "can update" do
expect(can_update).to be_truthy
expect(updated_dependencies).to eq [
{ "name" => "retry",
"package_manager" => "pub",
"previous_requirements" => [{
file: "pubspec.yaml", groups: ["direct"], requirement: "^2.0.0", source: nil
}],
"previous_version" => "2.0.0",
"requirements" => [{
file: "pubspec.yaml", groups: ["direct"], requirement: "^3.1.0", source: nil
}],
"version" => "3.1.0" }
]
end
end
context "library (has version)" do
let(:project) { "can_update_library" }
it "can update" do
expect(can_update).to be_truthy
expect(updated_dependencies).to eq [
{ "name" => "retry",
"package_manager" => "pub",
"previous_requirements" => [{
file: "pubspec.yaml", groups: ["direct"], requirement: "^2.0.0", source: nil
}],
"previous_version" => "2.0.0",
"requirements" => [{
file: "pubspec.yaml", groups: ["direct"], requirement: ">=2.0.0 <4.0.0", source: nil
}],
"version" => "3.1.0" }
]
end
end
end
context "with bump_versions strategy" do
let(:requirements_update_strategy) { "bump_versions" }
Expand Down