Skip to content

Commit

Permalink
Merge pull request #7787 from dependabot/jurre/show-latest-ignore-com…
Browse files Browse the repository at this point in the history
…mands-in-pr-body

Update ignore condition table
  • Loading branch information
jurre committed Aug 10, 2023
2 parents a3e2c09 + 7d6b963 commit cb26c07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions common/lib/dependabot/pull_request_creator/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,18 +529,18 @@ def ignore_conditions_table

# Filter out the conditions where from_config_file is false and dependency is in @dependencies
valid_ignore_conditions = @ignore_conditions.select do |ic|
!ic[:from_config_file] && dependencies.any? { |dep| dep.name == ic[:dependency_name] }
ic["source"] =~ /\A@dependabot ignore/ && dependencies.any? { |dep| dep.name == ic["dependency-name"] }
end

# 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
sorted_ignore_conditions = valid_ignore_conditions.sort_by { |ic| ic[:updated_at] || ic[:created_at] }.last(20)
sorted_ignore_conditions = valid_ignore_conditions.sort_by { |ic| ic["updated-at"] }.last(20)

# Map each condition to a row string
table_rows = sorted_ignore_conditions.map do |ic|
"| #{ic[:dependency_name]} | [#{ic[:version_requirement]}] |"
"| #{ic['dependency-name']} | [#{ic['version-requirement']}] |"
end

summary = "Most Recent Ignore Conditions Applied to This Pull Request"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2301,11 +2301,10 @@ def commits_details(base:, head:)
)
ignore_conditions.push(
{
dependency_name: "business#{i}",
version_requirement: "<= 1.#{i}.0",
from_config_file: false,
updated_at: Time.now,
created_at: Time.now - (i * 86_400)
"dependency-name" => "business#{i}",
"version-requirement" => "<= 1.#{i}.0",
"source" => "@dependabot ignore command",
"updated_at" => Time.now
}
)
end
Expand Down Expand Up @@ -2409,11 +2408,10 @@ def commits_details(base:, head:)
)
ignore_conditions.push(
{
dependency_name: "business#{i}",
version_requirement: "<= 1.#{i}.0",
from_config_file: false,
updated_at: Time.now,
created_at: Time.now - (i * 86_400)
"dependency-name" => "business#{i}",
"version-requirement" => "<= 1.#{i}.0",
"source" => "@dependabot ignore command",
"updated_at" => Time.now
}
)
end
Expand Down

0 comments on commit cb26c07

Please sign in to comment.