Class: Dependabot::Clients::Gitlab
- Inherits:
-
Object
- Object
- Dependabot::Clients::Gitlab
- Defined in:
- lib/dependabot/clients/gitlab.rb
Class Method Summary collapse
- .for_gitlab_dot_com(credentials:) ⇒ Object
-
.for_source(source:, credentials:) ⇒ Object
Constructor methods #.
Instance Method Summary collapse
-
#fetch_commit(repo, branch) ⇒ Object
VCS Interface #.
- #fetch_default_branch(repo) ⇒ Object
-
#initialize(**args) ⇒ Gitlab
constructor
Proxying #.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(**args) ⇒ Gitlab
Proxying #
54 55 56 |
# File 'lib/dependabot/clients/gitlab.rb', line 54 def initialize(**args) @client = ::Gitlab::Client.new(args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/dependabot/clients/gitlab.rb', line 58 def method_missing(method_name, *args, &block) if @client.respond_to?(method_name) mutatable_args = args.map(&:dup) @client.public_send(method_name, *mutatable_args, &block) else super end end |
Class Method Details
.for_gitlab_dot_com(credentials:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dependabot/clients/gitlab.rb', line 25 def self.for_gitlab_dot_com(credentials:) access_token = credentials. select { |cred| cred["type"] == "git_source" }. find { |cred| cred["host"] == "gitlab.com" }&. fetch("password") new( endpoint: "https://gitlab.com/api/v4", private_token: access_token || "" ) end |
.for_source(source:, credentials:) ⇒ Object
Constructor methods #
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dependabot/clients/gitlab.rb', line 12 def self.for_source(source:, credentials:) access_token = credentials. select { |cred| cred["type"] == "git_source" }. find { |cred| cred["host"] == source.hostname }&. fetch("password") new( endpoint: source.api_endpoint, private_token: access_token || "" ) end |
Instance Method Details
#fetch_commit(repo, branch) ⇒ Object
VCS Interface #
42 43 44 |
# File 'lib/dependabot/clients/gitlab.rb', line 42 def fetch_commit(repo, branch) branch(repo, branch).commit.id end |
#fetch_default_branch(repo) ⇒ Object
46 47 48 |
# File 'lib/dependabot/clients/gitlab.rb', line 46 def fetch_default_branch(repo) project(repo).default_branch end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
67 68 69 |
# File 'lib/dependabot/clients/gitlab.rb', line 67 def respond_to_missing?(method_name, include_private = false) @client.respond_to?(method_name) || super end |