Class: Dependabot::GitMetadataFetcher
- Inherits:
-
Object
- Object
- Dependabot::GitMetadataFetcher
- Defined in:
- lib/dependabot/git_metadata_fetcher.rb
Constant Summary collapse
- KNOWN_HOSTS =
/github\.com|bitbucket\.org|gitlab.com/i.freeze
Instance Method Summary collapse
-
#initialize(url:, credentials:) ⇒ GitMetadataFetcher
constructor
A new instance of GitMetadataFetcher.
- #ref_names ⇒ Object
- #tags ⇒ Object
- #upload_pack ⇒ Object
Constructor Details
#initialize(url:, credentials:) ⇒ GitMetadataFetcher
Returns a new instance of GitMetadataFetcher.
10 11 12 13 |
# File 'lib/dependabot/git_metadata_fetcher.rb', line 10 def initialize(url:, credentials:) @url = url @credentials = credentials end |
Instance Method Details
#ref_names ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/dependabot/git_metadata_fetcher.rb', line 27 def ref_names @ref_names ||= upload_pack.lines. select { |l| l.split(" ")[-1].start_with?("refs/tags", "refs/heads") }. map { |line| line.split(%r{ refs/(tags|heads)/}).last.strip }. reject { |l| l.end_with?("^{}") } end |
#tags ⇒ Object
21 22 23 24 25 |
# File 'lib/dependabot/git_metadata_fetcher.rb', line 21 def return [] unless upload_pack @tags ||= (upload_pack) end |
#upload_pack ⇒ Object
15 16 17 18 19 |
# File 'lib/dependabot/git_metadata_fetcher.rb', line 15 def upload_pack @upload_pack ||= fetch_upload_pack_for(url) rescue Octokit::ClientError raise Dependabot::GitDependenciesNotReachable, [url] end |