Class: Dependabot::Cargo::UpdateChecker::VersionResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/cargo/update_checker/version_resolver.rb

Constant Summary collapse

UNABLE_TO_UPDATE =
/Unable to update (?<url>.*?)$/
BRANCH_NOT_FOUND_REGEX =
/#{UNABLE_TO_UPDATE}.*to find branch `(?<branch>[^`]+)`/m
REVSPEC_PATTERN =
/revspec '.*' not found/
OBJECT_PATTERN =
/object not found - no match for id \(.*\)/
REF_NOT_FOUND_REGEX =
/#{UNABLE_TO_UPDATE}.*(#{REVSPEC_PATTERN}|#{OBJECT_PATTERN})/m
GIT_REF_NOT_FOUND_REGEX =
/Updating git repository `(?<url>[^`]*)`.*fatal: couldn't find remote ref/m
NOT_OUR_REF =

Note that as of Rust 1.80, git error message handling in the ‘cargo update` command changed. This change causes the NOT_OUR_REF error to appear before the UNABLE_TO_UPDATE error. Issue filed in Cargo project: github.com/rust-lang/cargo/issues/14621

/fatal: remote error: upload-pack: not our ref/
NOT_OUR_REF_REGEX =
/#{NOT_OUR_REF}.*#{UNABLE_TO_UPDATE}/m

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, credentials:, original_dependency_files:, prepared_dependency_files:) ⇒ VersionResolver

Returns a new instance of VersionResolver.



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

def initialize(dependency:, credentials:,
               original_dependency_files:, prepared_dependency_files:)
  @dependency = dependency
  @prepared_dependency_files = prepared_dependency_files
  @original_dependency_files = original_dependency_files
  @credentials = credentials
end

Instance Method Details

#latest_resolvable_versionObject



37
38
39
40
41
42
43
# File 'lib/dependabot/cargo/update_checker/version_resolver.rb', line 37

def latest_resolvable_version
  return @latest_resolvable_version if defined?(@latest_resolvable_version)

  @latest_resolvable_version = fetch_latest_resolvable_version
  rescue Dependabot::SharedHelpers::HelperSubprocessFailed => e
    raise Dependabot::DependencyFileNotResolvable, e.message
end