Class: Dependabot::Python::UpdateChecker::PipenvVersionResolver
- Inherits:
-
Object
- Object
- Dependabot::Python::UpdateChecker::PipenvVersionResolver
- Defined in:
- lib/dependabot/python/update_checker/pipenv_version_resolver.rb
Overview
This class does version resolution for Pipfiles. Its current approach is somewhat crude:
-
Unlock the dependency we’re checking in the Pipfile
-
Freeze all of the other dependencies in the Pipfile
-
Run ‘pipenv lock` and see what the result is
Unfortunately, Pipenv doesn’t resolve how we’d expect - it appears to just raise if the latest version can’t be resolved. Knowing that is still better than nothing, though.
Constant Summary collapse
- GIT_DEPENDENCY_UNREACHABLE_REGEX =
/Command "git clone -q (?<url>[^\s]+).*" failed/.freeze
- GIT_REFERENCE_NOT_FOUND_REGEX =
%r{"git checkout -q (?<tag>[^"]+)" .*/(?<name>.*?)(\\n'\]|$)}. freeze
- UNSUPPORTED_DEPS =
%w(pyobjc).freeze
- UNSUPPORTED_DEP_REGEX =
/"python setup\.py egg_info".*(?:#{UNSUPPORTED_DEPS.join("|")})/. freeze
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#dependency_files ⇒ Object
readonly
Returns the value of attribute dependency_files.
Instance Method Summary collapse
-
#initialize(dependency:, dependency_files:, credentials:) ⇒ PipenvVersionResolver
constructor
A new instance of PipenvVersionResolver.
- #latest_resolvable_version(requirement: nil) ⇒ Object
- #resolvable?(version:) ⇒ Boolean
Constructor Details
#initialize(dependency:, dependency_files:, credentials:) ⇒ PipenvVersionResolver
Returns a new instance of PipenvVersionResolver.
43 44 45 46 47 48 49 |
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 43 def initialize(dependency:, dependency_files:, credentials:) @dependency = dependency @dependency_files = dependency_files @credentials = credentials check_private_sources_are_reachable end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
41 42 43 |
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 41 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
41 42 43 |
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 41 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
41 42 43 |
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 41 def dependency_files @dependency_files end |
Instance Method Details
#latest_resolvable_version(requirement: nil) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 51 def latest_resolvable_version(requirement: nil) version_string = fetch_latest_resolvable_version_string(requirement: requirement) version_string.nil? ? nil : Python::Version.new(version_string) end |
#resolvable?(version:) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/dependabot/python/update_checker/pipenv_version_resolver.rb', line 58 def resolvable?(version:) @resolvable ||= {} return @resolvable[version] if @resolvable.key?(version) if fetch_latest_resolvable_version_string(requirement: "==#{version}") @resolvable[version] = true else @resolvable[version] = false end end |