Class: Dependabot::MetadataFinders::Base::CommitsFinder
- Inherits:
-
Object
- Object
- Dependabot::MetadataFinders::Base::CommitsFinder
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/metadata_finders/base/commits_finder.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #commits ⇒ Object
- #commits_url ⇒ Object
-
#initialize(source:, dependency:, credentials:) ⇒ CommitsFinder
constructor
A new instance of CommitsFinder.
- #new_tag ⇒ Object
Constructor Details
#initialize(source:, dependency:, credentials:) ⇒ CommitsFinder
Returns a new instance of CommitsFinder.
37 38 39 40 41 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 37 def initialize(source:, dependency:, credentials:) @source = source @dependency = dependency @credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
27 28 29 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 27 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
24 25 26 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 24 def dependency @dependency end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
21 22 23 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 21 def source @source end |
Instance Method Details
#commits ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 62 def commits return [] unless source return [] unless new_tag && previous_tag case T.must(source).provider when "github" then fetch_github_commits when "bitbucket" then fetch_bitbucket_commits when "gitlab" then fetch_gitlab_commits when "azure" then fetch_azure_commits when "codecommit" then [] # TODO: Fetch Codecommit commits else raise "Unexpected source provider '#{T.must(source).provider}'" end end |
#commits_url ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 44 def commits_url return unless source return if T.must(source).provider == "codecommit" # TODO: Fetch Codecommit commits path = case T.must(source).provider when "github" then github_compare_path(new_tag, previous_tag) when "bitbucket" then bitbucket_compare_path(new_tag, previous_tag) when "gitlab" then gitlab_compare_path(new_tag, previous_tag) when "azure" then azure_compare_path(new_tag, previous_tag) when "example" then "" else raise "Unexpected source provider '#{T.must(source).provider}'" end "#{T.must(source).url}/#{path}" end |
#new_tag ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 77 def new_tag new_version = dependency.version return T.must(new_version) if git_source?(dependency.requirements) && git_sha?(new_version) return new_ref if new_ref && ref_changed? = .select { |tag| tag_matches_version?(tag, new_version) } .sort_by(&:length) .find { |t| t.include?(dependency.name) } || .first end |