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

draft for dep change issues #10727

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all 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
Expand Up @@ -142,7 +142,9 @@ def check_and_update_pull_request(dependencies)
checker = update_checker_for(lead_dependency)
log_checking_for_update(lead_dependency)

Dependabot.logger.info("Latest version is #{checker.latest_version}")
lead_dep_latest_available_ver = checker.latest_version

Dependabot.logger.info("Latest version is #{lead_dep_latest_available_ver}")

return close_pull_request(reason: :up_to_date) if checker.up_to_date?

Expand Down Expand Up @@ -170,6 +172,15 @@ def check_and_update_pull_request(dependencies)
# Note that only notices with notice.show_alert set to true will be sent.
record_warning_notices(notices) if notices.any?

# Dependabot::Experiments.register(:existing_pr_version_match, false)

if Dependabot::Experiments.enabled?(:existing_pr_version_match) && (lead_dep_name &&
job.existing_pull_requests && pr_lead_dep_latest_ver(lead_dep_name,
lead_dep_latest_available_ver.to_s))
Dependabot.logger.info("Lead dependency version is already upto date in existing pr, Skipping updating PR.")
return
end

# NOTE: Gradle, Maven and Nuget dependency names can be case-insensitive
# and the dependency name in the security advisory often doesn't match
# what users have specified in their manifest.
Expand Down Expand Up @@ -197,6 +208,19 @@ def check_and_update_pull_request(dependencies)
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/CyclomaticComplexity

sig { params(lead_dep_name: String, existing_pr_lead_dep_ver: String).returns(T::Boolean) }
def pr_lead_dep_latest_ver(lead_dep_name, existing_pr_lead_dep_ver)
job.existing_pull_requests.each do |existing_pr|
existing_pr.dependencies.each do |deps|
next unless (deps.name.eql? lead_dep_name) && (deps.version.eql? existing_pr_lead_dep_ver)

Dependabot.logger.info("Matching entry found in existing PR. Dependency name: #{deps.name}, version: #{deps.version}") # rubocop:disable Layout/LineLength
return true
end
end
false
end

sig { params(checker: Dependabot::UpdateCheckers::Base).returns(Symbol) }
def requirements_to_unlock(checker)
if !checker.requirements_unlocked_or_can_be?
Expand Down
Loading