Class: Dependabot::Cargo::UpdateChecker

Inherits:
UpdateCheckers::Base
  • Object
show all
Defined in:
lib/dependabot/cargo/update_checker.rb,
lib/dependabot/cargo/update_checker/file_preparer.rb,
lib/dependabot/cargo/update_checker/version_resolver.rb,
lib/dependabot/cargo/update_checker/requirements_updater.rb,
lib/dependabot/cargo/update_checker/latest_version_finder.rb

Defined Under Namespace

Classes: FilePreparer, LatestVersionFinder, RequirementsUpdater, VersionResolver

Instance Method Summary collapse

Instance Method Details

#latest_resolvable_versionObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dependabot/cargo/update_checker.rb', line 32

def latest_resolvable_version
  return if path_dependency?

  @latest_resolvable_version ||=
    if git_dependency?
      latest_resolvable_version_for_git_dependency
    elsif git_subdependency?
      # TODO: Dependabot can't update git sub-dependencies yet, because
      # they can't be passed to GitCommitChecker.
      nil
    else
      fetch_latest_resolvable_version(unlock_requirement: true)
    end
end

#latest_resolvable_version_with_no_unlockObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/dependabot/cargo/update_checker.rb', line 60

def latest_resolvable_version_with_no_unlock
  return if path_dependency?

  @latest_resolvable_version_with_no_unlock ||=
    if git_dependency?
      latest_resolvable_commit_with_unchanged_git_source
    else
      fetch_latest_resolvable_version(unlock_requirement: false)
    end
end

#latest_versionObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dependabot/cargo/update_checker.rb', line 17

def latest_version
  return if path_dependency?

  @latest_version =
    if git_dependency?
      latest_version_for_git_dependency
    elsif git_subdependency?
      # TODO: Dependabot can't update git sub-dependencies yet, because
      # they can't be passed to GitCommitChecker.
      nil
    else
      latest_version_finder.latest_version
    end
end

#lowest_resolvable_security_fix_versionObject



51
52
53
54
55
56
57
58
# File 'lib/dependabot/cargo/update_checker.rb', line 51

def lowest_resolvable_security_fix_version
  raise "Dependency not vulnerable!" unless vulnerable?

  return @lowest_resolvable_security_fix_version if defined?(@lowest_resolvable_security_fix_version)

  @lowest_resolvable_security_fix_version =
    fetch_lowest_resolvable_security_fix_version
end

#lowest_security_fix_versionObject



47
48
49
# File 'lib/dependabot/cargo/update_checker.rb', line 47

def lowest_security_fix_version
  latest_version_finder.lowest_security_fix_version
end

#requirements_unlocked_or_can_be?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/dependabot/cargo/update_checker.rb', line 80

def requirements_unlocked_or_can_be?
  !requirements_update_strategy.lockfile_only?
end

#requirements_update_strategyObject



84
85
86
87
88
89
90
# File 'lib/dependabot/cargo/update_checker.rb', line 84

def requirements_update_strategy
  # If passed in as an option (in the base class) honour that option
  return @requirements_update_strategy if @requirements_update_strategy

  # Otherwise, widen ranges for libraries and bump versions for apps
  library? ? RequirementsUpdateStrategy::BumpVersionsIfNecessary : RequirementsUpdateStrategy::BumpVersions
end

#updated_requirementsObject



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

def updated_requirements
  RequirementsUpdater.new(
    requirements: dependency.requirements,
    updated_source: updated_source,
    target_version: target_version,
    update_strategy: requirements_update_strategy
  ).updated_requirements
end