Class: PdkSync::GitPlatformClient
- Inherits:
-
Object
- Object
- PdkSync::GitPlatformClient
- Defined in:
- lib/pdksync/gitplatformclient.rb
Instance Method Summary collapse
-
#create_pull_request(project, target_branch, source_branch, title, message) ⇒ PdkSync::PullRequest
A pdksync pull request object for the newly created pull/merge request for consumption by pdksync main.
-
#delete_branch(project, branch_name) ⇒ Boolean
True on success, false on failure.
-
#initialize(git_platform, git_platform_access_settings) ⇒ GitPlatformClient
constructor
A new instance of GitPlatformClient.
-
#labels(project) ⇒ Array
List of available labels in the project.
-
#repository?(project) ⇒ Boolean
True if the project exists, false otherwise.
-
#update_issue(project, id, options) ⇒ Object
A pull/merge request object of the updated pull/merge request.
Constructor Details
#initialize(git_platform, git_platform_access_settings) ⇒ GitPlatformClient
Returns a new instance of GitPlatformClient.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pdksync/gitplatformclient.rb', line 18 def initialize(git_platform, git_platform_access_settings) @git_platform = git_platform # TODO: raise exceptions when git_platform_access_settings hash is not # set up correctly? Or let PdkSync::GithubClient or PdkSync::GitlabClient # raise errors later and let them propagate upwards? access_token = git_platform_access_settings[:access_token] @client = case git_platform when :github require 'pdksync/githubclient' PdkSync::GithubClient.new(access_token, git_platform_access_settings[:api_endpoint]) when :gitlab require 'pdksync/gitlabclient' gitlab_api_endpoint = git_platform_access_settings[:gitlab_api_endpoint] || git_platform_access_settings[:api_endpoint] PdkSync::GitlabClient.new(access_token, gitlab_api_endpoint) end end |
Instance Method Details
#create_pull_request(project, target_branch, source_branch, title, message) ⇒ PdkSync::PullRequest
Returns A pdksync pull request object for the newly created pull/merge request for consumption by pdksync main.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pdksync/gitplatformclient.rb', line 64 def create_pull_request(project, target_branch, source_branch, title, ) client_pr = @client.create_pull_request(project, target_branch, source_branch, title, ) pr = case @git_platform when :github PdkSync::PullRequest.github(client_pr) when :gitlab PdkSync::PullRequest.gitlab(client_pr) end pr end |
#delete_branch(project, branch_name) ⇒ Boolean
Returns true on success, false on failure.
106 107 108 |
# File 'lib/pdksync/gitplatformclient.rb', line 106 def delete_branch(project, branch_name) @client.delete_branch(project, branch_name) end |
#labels(project) ⇒ Array
Returns List of available labels in the project.
80 81 82 |
# File 'lib/pdksync/gitplatformclient.rb', line 80 def labels(project) @client.labels(project) end |
#repository?(project) ⇒ Boolean
Returns true if the project exists, false otherwise.
42 43 44 |
# File 'lib/pdksync/gitplatformclient.rb', line 42 def repository?(project) @client.repository?(project) end |
#update_issue(project, id, options) ⇒ Object
This method is specifically used to set labels for a pull/merge request
Returns A pull/merge request object of the updated pull/merge request.
95 96 97 |
# File 'lib/pdksync/gitplatformclient.rb', line 95 def update_issue(project, id, ) @client.update_issue(project, id, ) end |