Class: Dependabot::FileFetchers::Base
- Inherits:
-
Object
- Object
- Dependabot::FileFetchers::Base
- Defined in:
- lib/hack/dependabot-core/common/lib/dependabot/fire_fetchers/base.rb
Instance Method Summary collapse
-
#_fetch_file_content_fully_specified(provider, repo, path, commit) ⇒ Object
override.
-
#_fetch_repo_contents_fully_specified(provider, repo, path, commit) ⇒ Object
override.
- #_gitea_repo_contents(repo, path, commit) ⇒ Object
-
#client_for_provider ⇒ Object
override.
- #gitea_client ⇒ Object
Instance Method Details
#_fetch_file_content_fully_specified(provider, repo, path, commit) ⇒ Object
override
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hack/dependabot-core/common/lib/dependabot/fire_fetchers/base.rb', line 42 def _fetch_file_content_fully_specified(provider, repo, path, commit) case provider when "github" _fetch_file_content_from_github(path, repo, commit) when "gitlab" tmp = gitlab_client.get_file(repo, path, commit).content Base64.decode64(tmp).force_encoding("UTF-8").encode when "azure" azure_client.fetch_file_contents(commit, path) when "gitea" tmp = gitea_client.fetch_repo_contents(commit, path) Base64.decode64(tmp.fetch('content')).force_encoding("UTF-8").encode when "bitbucket" bitbucket_client.fetch_file_contents(repo, commit, path) when "codecommit" codecommit_client.fetch_file_contents(repo, commit, path) else raise "Unsupported provider '#{source.provider}'." end end |
#_fetch_repo_contents_fully_specified(provider, repo, path, commit) ⇒ Object
override
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hack/dependabot-core/common/lib/dependabot/fire_fetchers/base.rb', line 10 def _fetch_repo_contents_fully_specified(provider, repo, path, commit) case provider when "github" _github_repo_contents(repo, path, commit) when "gitlab" _gitlab_repo_contents(repo, path, commit) when "azure" _azure_repo_contents(path, commit) when "bitbucket" _bitbucket_repo_contents(repo, path, commit) when "gitea" _gitea_repo_contents(repo, path, commit) when "codecommit" _codecommit_repo_contents(repo, path, commit) else raise "Unsupported provider '#{provider}'." end end |
#_gitea_repo_contents(repo, path, commit) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hack/dependabot-core/common/lib/dependabot/fire_fetchers/base.rb', line 28 def _gitea_repo_contents(repo, path, commit) response = gitea_client.fetch_repo_contents(commit, path) response.map do |file| OpenStruct.new( name: file.fetch('name'), path: file.fetch('path'), type: file.fetch('type'), size: file.fetch('size') ) end end |
#client_for_provider ⇒ Object
override
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/hack/dependabot-core/common/lib/dependabot/fire_fetchers/base.rb', line 63 def client_for_provider case source.provider when "github" then github_client when "gitlab" then gitlab_client when "azure" then azure_client when "gitea" then gitea_client when "bitbucket" then bitbucket_client when "codecommit" then codecommit_client else raise "Unsupported provider '#{source.provider}'." end end |
#gitea_client ⇒ Object
75 76 77 78 |
# File 'lib/hack/dependabot-core/common/lib/dependabot/fire_fetchers/base.rb', line 75 def gitea_client @gitea_client ||= Dependabot::Clients::Gitea.for_source(source: source, credentials: credentials) end |