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

fix ignore conditions nil error #9560

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# typed: strict
# frozen_string_literal: true

require "time"
require "pathname"
require "sorbet-runtime"

Expand Down Expand Up @@ -127,6 +128,7 @@ def pr_message
truncate_pr_message(msg)
rescue StandardError => e
Dependabot.logger.error("Error while generating PR message: #{e.message}")
Dependabot.logger.error(e.backtrace&.join("\n"))
jakecoffman marked this conversation as resolved.
Show resolved Hide resolved
suffixed_pr_message_header + prefixed_pr_message_footer
end

Expand Down Expand Up @@ -162,6 +164,7 @@ def commit_message
message
rescue StandardError => e
Dependabot.logger.error("Error while generating commit message: #{e.message}")
Dependabot.logger.error(e.backtrace&.join("\n"))
message = commit_subject
message += "\n\n" + T.must(message_trailers) if message_trailers
message
Expand Down Expand Up @@ -276,6 +279,7 @@ def pr_name_prefix
pr_name_prefixer.pr_name_prefix
rescue StandardError => e
Dependabot.logger.error("Error while generating PR name: #{e.message}")
Dependabot.logger.error(e.backtrace&.join("\n"))
""
end

Expand Down Expand Up @@ -735,9 +739,9 @@ def ignore_conditions_table
# Return an empty string if no valid ignore conditions after filtering
return "" if valid_ignore_conditions.empty?

# Sort them by updated_at (or created_at if updated_at is nil), taking the latest 20
# Sort them by updated_at, taking the latest 20
sorted_ignore_conditions = valid_ignore_conditions.sort_by do |ic|
ic["updated_at"].nil? ? T.must(ic["created_at"]) : T.must(ic["updated_at"])
ic["updated-at"].nil? ? Time.at(0).iso8601 : T.must(ic["updated-at"])
jakecoffman marked this conversation as resolved.
Show resolved Hide resolved
end.last(20)

# Map each condition to a row string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@ def commits_details(base:, head:)
"dependency-name" => "business#{i}",
"version-requirement" => "<= 1.#{i}.0",
"source" => "@dependabot ignore command",
"updated_at" => Time.now
"updated-at" => i == 4 ? nil : Time.now.iso8601
}
)
end
Expand All @@ -2655,9 +2655,9 @@ def commits_details(base:, head:)
expect(pr_message).to include(
"| Dependency Name | Ignore Conditions |\n" \
"| --- | --- |\n" \
"| business4 | [<= 1.4.0] |\n" \
"| business2 | [<= 1.2.0] |\n" \
"| business3 | [<= 1.3.0] |\n" \
"| business4 | [<= 1.4.0] |\n" \
"| business5 | [<= 1.5.0] |\n"
)
end
Expand Down
Loading