Skip to content

Commit

Permalink
refined the warning and error message
Browse files Browse the repository at this point in the history
fixed specs
  • Loading branch information
kbukum1 committed Aug 15, 2024
1 parent c5fd850 commit a9af4de
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 42 deletions.
8 changes: 4 additions & 4 deletions common/lib/dependabot/notices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ def self.generate_pm_deprecation_notice(package_manager)
## Create a warning markdown message
markdown = "> [!WARNING]\n"
## Add the deprecation warning to the message
markdown += "> #{message}\n\n"
markdown += "> #{message}\n>\n"

## Add the supported versions to the message
unless supported_versions_message.empty?
message += "\n#{supported_versions_message}\n"
markdown += "> #{supported_versions_message}\n\n"
markdown += "> #{supported_versions_message}\n>\n"
end

Notice.new(
Expand Down Expand Up @@ -144,12 +144,12 @@ def self.generate_pm_unsupported_notice(package_manager)
## Create an error markdown message
markdown = "> [!IMPORTANT]\n"
## Add the error message to the message
markdown += "> #{message}\n\n"
markdown += "> #{message}\n>\n"

## Add the supported versions to the message
unless supported_versions_message.empty?
message += "\n#{supported_versions_message}\n"
markdown += "> #{supported_versions_message}\n\n"
markdown += "> #{supported_versions_message}\n>\n"
end

Notice.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def pr_message
"#{prefixed_pr_message_footer}"

truncate_pr_message(msg)
puts "\n#{msg}\n"
rescue StandardError => e
suppress_error("PR message", e)
suffixed_pr_message_header + prefixed_pr_message_footer
Expand Down
16 changes: 8 additions & 8 deletions common/spec/dependabot/notices_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
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"
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
})
end
end
Expand All @@ -144,8 +144,8 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
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"
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
})
end
end
Expand Down Expand Up @@ -196,8 +196,8 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
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"
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
})
end
end
Expand All @@ -224,8 +224,8 @@ def initialize(name:, version:, deprecated_versions: [], unsupported_versions: [
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"
markdown: "> [!IMPORTANT]\n> Dependabot no longer supports `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
})
end
end
Expand Down
36 changes: 18 additions & 18 deletions common/spec/dependabot/pull_request_creator/message_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3325,9 +3325,9 @@ def commits_details(base:, head:)
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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
)]
end

Expand All @@ -3343,17 +3343,17 @@ def commits_details(base:, head:)
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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
), Dependabot::Notice.new(
mode: "INFO",
type: "bundler_nosupport_due_info",
mode: "ERROR",
type: "bundler_unsupported_error",
package_manager_name: "bundler",
message: "The support for bundler v1 is due 30th of August!" \
"Please upgrade the bundler to one of the following versions soon!: v2, v3.",
markdown: "> [!INFO]\n> The support for bundler v1 is due 30th of August!\n\n" \
"> Please upgrade the bundler to one of the following versions soon!: v2, v3."
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"
)]
end

Expand All @@ -3371,17 +3371,17 @@ def commits_details(base:, head:)
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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
), 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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
)]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
).to_hash
]
)
Expand Down Expand Up @@ -163,9 +163,9 @@
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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
}
)
create_group_update_pull_request.perform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ def support_later_versions?
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.",
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n\n" \
"> Please upgrade to one of the following versions: v2, v3."
"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"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@
package_manager_name: "bundler",
details: {
message: "Dependabot will stop supporting `bundler` `v1`!\n" \
"Please upgrade to one of the following versions: v2, v3.",
"Please upgrade to one of the following versions: v2, 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."
markdown: "> [!WARNING]\n> Dependabot will stop supporting `bundler` `v1`!\n>\n" \
"> Please upgrade to one of the following versions: v2, v3.\n>\n"
}
}])
expect(refresh_security_update_pull_request).to receive(:create_pull_request)
Expand Down

0 comments on commit a9af4de

Please sign in to comment.