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
Use table summary for large groups of dependencies #7463
Conversation
When five or more dependencies are being updated in a pull request, render the updates as a table for legibility.
def table(rows) | ||
[ | ||
table_header(rows[0]), | ||
rows[1..].map { |r| table_row(r) }, | ||
].join("\n") | ||
end | ||
|
||
def table_header(row) | ||
[ | ||
table_row(row), | ||
table_row(["---"] * row.count), | ||
].join("\n") | ||
end | ||
|
||
def table_row(row) | ||
"| #{row.join(' | ')} |" | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really clean interface. Thanks!
elsif update_count > 1 | ||
" #{dependency_links[0..-2].join(', ')} and #{dependency_links[-1]}." | ||
else | ||
": #{dependency_links.first}." | ||
" #{dependency_links.first}." | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a test for when there are less than 5 updates to make sure the formatting is correct outside of a table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be covered by a few existing tests:
dependabot-core/common/spec/dependabot/pull_request_creator/message_builder_spec.rb
Line 1878 in 86b7340
context "for a dependency group", :vcr do dependabot-core/common/spec/dependabot/pull_request_creator/message_builder_spec.rb
Line 1951 in 86b7340
context "with two dependencies with the same name" do dependabot-core/common/spec/dependabot/pull_request_creator/message_builder_spec.rb
Line 1972 in 86b7340
context "with three dependencies", :vcr do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Use table summary for large groups of dependencies
When a pull request is being created that updates five or more dependencies, render the updates as a table for legibility.