Class: Dependabot::Python::UpdateChecker::LatestVersionFinder

Inherits:
Dependabot::Package::PackageLatestVersionFinder
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/update_checker/latest_version_finder.rb

Instance Method Summary collapse

Instance Method Details

#cooldown_enabled?Boolean

Returns:

  • (Boolean)


70
71
72
73
74
75
76
77
78
# File 'lib/dependabot/python/update_checker/latest_version_finder.rb', line 70

def cooldown_enabled?
  return false if cooldown_options.nil?

  cooldown = T.must(cooldown_options)
  cooldown.default_days.to_i.positive? ||
    cooldown.semver_major_days.to_i.positive? ||
    cooldown.semver_minor_days.to_i.positive? ||
    cooldown.semver_patch_days.to_i.positive?
end

#latest_version_tag(git_commit_checker:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dependabot/python/update_checker/latest_version_finder.rb', line 30

def latest_version_tag(git_commit_checker:)
  return git_commit_checker.local_tag_for_latest_version unless cooldown_enabled?

  allowed_version_tags = git_commit_checker.local_tags_for_allowed_versions
  tags_in_cooldown = select_version_tags_in_cooldown_period(git_commit_checker)

  return max_version_from_tags(allowed_version_tags) if tags_in_cooldown.empty?

  filtered_tags = allowed_version_tags.reject do |tag|
    tags_in_cooldown.include?(tag[:tag])
  end

  if filtered_tags.empty?
    Dependabot.logger.info("All git tags filtered by cooldown for #{dependency.name}, returning nil")
    return nil
  end

  filtered_count = allowed_version_tags.count - filtered_tags.count
  if filtered_count.positive?
    Dependabot.logger.info("Filtered #{filtered_count} git tags due to cooldown for #{dependency.name}")
  end

  max_version_from_tags(filtered_tags)
rescue StandardError => e
  Dependabot.logger.error("Error fetching latest version tag: #{e.message}")
  git_commit_checker.local_tag_for_latest_version
end

#package_detailsObject



61
62
63
64
65
66
67
# File 'lib/dependabot/python/update_checker/latest_version_finder.rb', line 61

def package_details
  @package_details ||= Package::PackageDetailsFetcher.new(
    dependency: dependency,
    dependency_files: dependency_files,
    credentials: credentials
  ).fetch
end