From 37c97f50b744df21c0ab7e618aeecc6c418cce8a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 3 Mar 2023 22:09:23 -0800 Subject: [PATCH 1/2] Update update_checker.rb --- pub/lib/dependabot/pub/update_checker.rb | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/pub/lib/dependabot/pub/update_checker.rb b/pub/lib/dependabot/pub/update_checker.rb index 1fecf6f04d..01539b0766 100644 --- a/pub/lib/dependabot/pub/update_checker.rb +++ b/pub/lib/dependabot/pub/update_checker.rb @@ -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 From 1b2ca22def843fe053986e48cfaa47d231db2e7a Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Fri, 10 Mar 2023 12:51:25 +0000 Subject: [PATCH 2/2] Update tests --- .../dependabot/pub/update_checker_spec.rb | 40 +------------------ 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/pub/spec/dependabot/pub/update_checker_spec.rb b/pub/spec/dependabot/pub/update_checker_spec.rb index 65e7ebb58b..22df319a7f 100644 --- a/pub/spec/dependabot/pub/update_checker_spec.rb +++ b/pub/spec/dependabot/pub/update_checker_spec.rb @@ -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" } ] @@ -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" } ] @@ -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" }