Skip to content

Commit

Permalink
draft for dep change issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-sandhu committed Oct 4, 2024
1 parent 5ffb7a2 commit 0b682d6
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,18 @@ 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?

if 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, PR update not required.") # rubocop:disable Layout/LineLength
return
end

requirements_to_unlock = requirements_to_unlock(checker)
log_requirements_for_update(requirements_to_unlock, checker)

Expand Down Expand Up @@ -197,6 +205,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

0 comments on commit 0b682d6

Please sign in to comment.