Class: Dependabot::PreCommit::UpdateChecker

Inherits:
UpdateCheckers::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/pre_commit/update_checker.rb,
lib/dependabot/pre_commit/update_checker/latest_version_finder.rb

Defined Under Namespace

Classes: LatestVersionFinder

Instance Method Summary collapse

Instance Method Details

#latest_resolvable_versionObject



39
40
41
# File 'lib/dependabot/pre_commit/update_checker.rb', line 39

def latest_resolvable_version
  latest_version
end

#latest_resolvable_version_with_no_unlockObject



44
45
46
# File 'lib/dependabot/pre_commit/update_checker.rb', line 44

def latest_resolvable_version_with_no_unlock
  dependency.version
end

#latest_versionObject



29
30
31
32
33
34
35
36
# File 'lib/dependabot/pre_commit/update_checker.rb', line 29

def latest_version
  return additional_dependency_latest_version if additional_dependency?

  @latest_version ||= T.let(
    T.must(latest_version_finder).latest_release_version,
    T.nilable(T.any(String, Gem::Version))
  )
end

#updated_requirementsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dependabot/pre_commit/update_checker.rb', line 49

def updated_requirements
  return additional_dependency_updated_requirements if additional_dependency?

  dependency.requirements.map do |req|
    source = T.cast(req[:source], T.nilable(T::Hash[Symbol, T.untyped]))
    updated = updated_ref(source)
    next req unless updated

    current = T.cast(source&.[](:ref), T.nilable(String))

    # Maintain short git hash when the updated SHA starts with the current SHA
    if T.cast(req[:type], T.nilable(String)) == "git" &&
       git_commit_checker.ref_looks_like_commit_sha?(updated) &&
       current && git_commit_checker.ref_looks_like_commit_sha?(current) &&
       updated.start_with?(current)
      next req
    end

    new_source = T.must(source).merge(ref: updated)
     = (req, updated)
    req.merge(source: new_source, metadata: )
  end
end