Class: Dependabot::Bundler::UpdateChecker::LatestVersionFinder::DependencySource
- Inherits:
-
Object
- Object
- Dependabot::Bundler::UpdateChecker::LatestVersionFinder::DependencySource
- Extended by:
- T::Sig
- Includes:
- SharedBundlerHelpers
- Defined in:
- lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb
Constant Summary collapse
- RUBYGEMS =
"rubygems"- PRIVATE_REGISTRY =
"private"- GIT =
"git"- OTHER =
"other"
Constants included from SharedBundlerHelpers
SharedBundlerHelpers::GIT_REF_REGEX, SharedBundlerHelpers::GIT_REGEX, SharedBundlerHelpers::PATH_REGEX, SharedBundlerHelpers::RETRYABLE_ERRORS, SharedBundlerHelpers::RETRYABLE_PRIVATE_REGISTRY_ERRORS
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.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#repo_contents_path ⇒ Object
readonly
Returns the value of attribute repo_contents_path.
Instance Method Summary collapse
- #git? ⇒ Boolean
-
#initialize(dependency:, dependency_files:, credentials:, options:) ⇒ DependencySource
constructor
A new instance of DependencySource.
- #latest_git_version_details ⇒ Object
- #versions ⇒ Object
Methods included from SharedBundlerHelpers
#base_directory, #handle_bundler_errors, #in_a_native_bundler_context, #inaccessible_git_dependencies, #jfrog_source, #private_registry_credentials, #retryable_error?, #write_temporary_dependency_files
Constructor Details
#initialize(dependency:, dependency_files:, credentials:, options:) ⇒ DependencySource
Returns a new instance of DependencySource.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 49 def initialize( dependency:, dependency_files:, credentials:, options: ) @dependency = dependency @dependency_files = dependency_files @repo_contents_path = T.let(nil, T.nilable(String)) @credentials = credentials @options = @source_type = T.let(nil, T.nilable(String)) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
36 37 38 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 36 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
27 28 29 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 27 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
30 31 32 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 30 def dependency_files @dependency_files end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
39 40 41 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 39 def @options end |
#repo_contents_path ⇒ Object (readonly)
Returns the value of attribute repo_contents_path.
33 34 35 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 33 def repo_contents_path @repo_contents_path end |
Instance Method Details
#git? ⇒ Boolean
111 112 113 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 111 def git? source_type == GIT end |
#latest_git_version_details ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 84 def latest_git_version_details return unless git? source_details = dependency.requirements.map { |r| r.fetch(:source) } .uniq.compact.first SharedHelpers.with_git_configured(credentials: credentials) do in_a_native_bundler_context do |tmp_dir| NativeHelpers.run_bundler_subprocess( bundler_version: bundler_version, function: "dependency_source_latest_git_version", options: , args: { dir: tmp_dir, gemfile_name: T.must(gemfile).name, dependency_name: dependency.name, credentials: credentials, dependency_source_url: source_details[:url], dependency_source_branch: source_details[:branch] } ) end end.transform_keys(&:to_sym) end |
#versions ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb', line 66 def versions return rubygems_versions if dependency.name == "bundler" return rubygems_versions unless gemfile case source_type when OTHER, GIT [] when PRIVATE_REGISTRY private_registry_versions else rubygems_versions end end |