Class: Dependabot::UpdateCheckers::Rust::Cargo

Inherits:
Base
  • Object
show all
Defined in:
lib/dependabot/update_checkers/rust/cargo.rb,
lib/dependabot/update_checkers/rust/cargo/file_preparer.rb,
lib/dependabot/update_checkers/rust/cargo/version_resolver.rb,
lib/dependabot/update_checkers/rust/cargo/requirements_updater.rb

Defined Under Namespace

Classes: FilePreparer, RequirementsUpdater, VersionResolver

Instance Attribute Summary

Attributes inherited from Base

#credentials, #dependency, #dependency_files, #ignored_versions, #requirements_update_strategy

Instance Method Summary collapse

Methods inherited from Base

#can_update?, #initialize, #requirement_class, #requirements_unlocked_or_can_be?, #up_to_date?, #updated_dependencies, #version_class

Constructor Details

This class inherits a constructor from Dependabot::UpdateCheckers::Base

Instance Method Details

#latest_resolvable_versionObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dependabot/update_checkers/rust/cargo.rb', line 35

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



50
51
52
53
54
55
56
57
58
59
# File 'lib/dependabot/update_checkers/rust/cargo.rb', line 50

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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dependabot/update_checkers/rust/cargo.rb', line 15

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
      versions = available_versions
      versions.reject!(&:prerelease?) unless wants_prerelease?
      versions.reject! do |v|
        ignore_reqs.any? { |r| r.satisfied_by?(v) }
      end
      versions.max
    end
end

#updated_requirementsObject



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

def updated_requirements
  RequirementsUpdater.new(
    requirements: dependency.requirements,
    updated_source: updated_source,
    latest_resolvable_version: latest_resolvable_version&.to_s,
    latest_version: latest_version&.to_s,
    library: library?,
    update_strategy: requirement_update_strategy
  ).updated_requirements
end