Class: Dependabot::MetadataFinders::Base::CommitsFinder
- Inherits:
-
Object
- Object
- Dependabot::MetadataFinders::Base::CommitsFinder
- 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.
18 19 20 21 22 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 18 def initialize(source:, dependency:, credentials:) @source = source @dependency = dependency @credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
16 17 18 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 16 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
16 17 18 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 16 def dependency @dependency end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
16 17 18 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 16 def source @source end |
Instance Method Details
#commits ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 40 def commits return [] unless source return [] unless new_tag && previous_tag case 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 '#{source.provider}'" end end |
#commits_url ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 24 def commits_url return unless source return if source.provider == "codecommit" # TODO: Fetch Codecommit commits path = case 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) else raise "Unexpected source provider '#{source.provider}'" end "#{source.url}/#{path}" end |
#new_tag ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 54 def new_tag new_version = dependency.version return 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 |