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.
17 18 19 20 21 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 17 def initialize(source:, dependency:, credentials:) @source = source @dependency = dependency @credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
15 16 17 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 15 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
15 16 17 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 15 def dependency @dependency end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
15 16 17 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 15 def source @source end |
Instance Method Details
#commits ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 39 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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 23 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
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/dependabot/metadata_finders/base/commits_finder.rb', line 53 def new_tag new_version = dependency.version if git_source?(dependency.requirements) && git_sha?(new_version) return new_version end return new_ref if git_source?(dependency.requirements) && ref_changed? = . select { |tag| tag_matches_version?(tag, new_version) }. sort_by(&:length) .find { |t| t.include?(dependency.name) } || .first end |