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
rubocop:disable Metrics/CyclomaticComplexity.
- #commits_url ⇒ Object
-
#initialize(source:, dependency:, credentials:) ⇒ CommitsFinder
constructor
A new instance of CommitsFinder.
-
#new_tag ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity.
Constructor Details
#initialize(source:, dependency:, credentials:) ⇒ CommitsFinder
Returns a new instance of CommitsFinder.
16 17 18 19 20 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 16 def initialize(source:, dependency:, credentials:) @source = source @dependency = dependency @credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
14 15 16 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 14 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
14 15 16 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 14 def dependency @dependency end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
14 15 16 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 14 def source @source end |
Instance Method Details
#commits ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 38 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 [] # TODO: Fetch Azure commits else raise "Unexpected source provider '#{source.provider}'" end end |
#commits_url ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 22 def commits_url return unless source return if source.provider == "azure" # TODO: Fetch Azure 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) else raise "Unexpected source provider '#{source.provider}'" end "#{source.url}/#{path}" end |
#new_tag ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 52 def new_tag new_version = dependency.version return new_version if git_source?(dependency.requirements) = . select { |t| t =~ version_regex(new_version) }. sort_by(&:length) .find { |t| t.include?(dependency.name) } || .first end |