Skip to content

Commit

Permalink
reformatted the deprecation and error message for bundler version sup…
Browse files Browse the repository at this point in the history
…port (#10450)
  • Loading branch information
kbukum1 authored Aug 16, 2024
1 parent 945beb0 commit 40b0760
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 60 deletions.
14 changes: 9 additions & 5 deletions common/lib/dependabot/notices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ def to_hash
def self.generate_supported_versions_message(supported_versions, support_later_versions)
return "" unless supported_versions&.any?

versions_string = supported_versions.map { |version| "v#{version}" }.join(", ")
versions_string = supported_versions.map { |version| "`v#{version}`" }

later_message = support_later_versions ? " or later" : ""
versions_string[-1] = "or #{versions_string[-1]}" if versions_string.count > 1 && !support_later_versions

return "Please upgrade to version `#{versions_string}`#{later_message}." if supported_versions.count == 1
versions_string = versions_string.join(", ")

later_message = support_later_versions ? ", or later" : ""

return "Please upgrade to version #{versions_string}#{later_message}." if supported_versions.count == 1

"Please upgrade to one of the following versions: #{versions_string}#{later_message}."
end
Expand Down Expand Up @@ -102,7 +106,7 @@ def self.generate_pm_deprecation_notice(package_manager)
package_manager.support_later_versions?
)
notice_type = "#{package_manager.name}_deprecated_#{mode.downcase}"
message = "Dependabot will stop supporting `#{package_manager.name}` `v#{package_manager.version}`!"
message = "Dependabot will stop supporting `#{package_manager.name} v#{package_manager.version}`!"
## Create a warning markdown message
markdown = "> [!WARNING]\n"
## Add the deprecation warning to the message
Expand Down Expand Up @@ -140,7 +144,7 @@ def self.generate_pm_unsupported_notice(package_manager)
package_manager.support_later_versions?
)
notice_type = "#{package_manager.name}_unsupported_#{mode.downcase}"
message = "Dependabot no longer supports `#{package_manager.name}` `v#{package_manager.version}`!"
message = "Dependabot no longer supports `#{package_manager.name} v#{package_manager.version}`!"
## Create an error markdown message
markdown = "> [!IMPORTANT]\n"
## Add the error message to the message
Expand Down
38 changes: 19 additions & 19 deletions common/spec/dependabot/notices_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [

it "returns the correct message" do
expect(generate_supported_versions_message)
.to eq("Please upgrade to version `v2` or later.")
.to eq("Please upgrade to version `v2`, or later.")
end
end

Expand All @@ -60,7 +60,7 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [

it "returns the correct message" do
expect(generate_supported_versions_message)
.to eq("Please upgrade to one of the following versions: v2, v3, v4.")
.to eq("Please upgrade to one of the following versions: `v2`, `v3`, or `v4`.")
end
end

Expand All @@ -73,7 +73,7 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [

it "returns the correct message" do
expect(generate_supported_versions_message)
.to eq("Please upgrade to one of the following versions: v2, v3, v4 or later.")
.to eq("Please upgrade to one of the following versions: `v2`, `v3`, `v4`, or later.")
end
end

Expand Down Expand Up @@ -124,10 +124,10 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
})
end
end
Expand All @@ -142,10 +142,10 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
mode: "ERROR",
type: "bundler_unsupported_error",
package_manager_name: "bundler",
message: "Dependabot no longer supports `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot no longer supports `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
})
end
end
Expand Down Expand Up @@ -194,10 +194,10 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
})
end
end
Expand All @@ -222,10 +222,10 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
mode: "ERROR",
type: "bundler_unsupported_error",
package_manager_name: "bundler",
message: "Dependabot no longer supports `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot no longer supports `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
})
end
end
Expand Down
40 changes: 20 additions & 20 deletions common/spec/dependabot/pull_request_creator/message_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3324,10 +3324,10 @@ def commits_details(base:, head:)
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
)]
end

Expand All @@ -3342,18 +3342,18 @@ def commits_details(base:, head:)
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
), Dependabot::Notice.new(
mode: "ERROR",
type: "bundler_unsupported_error",
package_manager_name: "bundler",
message: "Dependabot no longer supports `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot no longer supports `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
)]
end

Expand All @@ -3370,18 +3370,18 @@ def commits_details(base:, head:)
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
), Dependabot::Notice.new(
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
)]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
).to_hash
]
)
Expand Down Expand Up @@ -162,10 +162,10 @@
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
}
)
create_group_update_pull_request.perform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ def support_later_versions?
mode: "WARN",
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@
type: "bundler_deprecated_warn",
package_manager_name: "bundler",
details: {
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.\n",
message: "Dependabot will stop supporting `bundler v1`!\n" \
"Please upgrade to one of the following versions: `v2`, or `v3`.\n",
current_version: "v1",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler v1`!\n>\n" \
"> Please upgrade to one of the following versions: `v2`, or `v3`.\n>\n"
}
}])
expect(refresh_security_update_pull_request).to receive(:create_pull_request)
Expand Down

0 comments on commit 40b0760

Please sign in to comment.