Class: Leash::Integration::GithubClient
- Inherits:
-
Object
- Object
- Leash::Integration::GithubClient
- Defined in:
- lib/leash/integration/github.rb
Instance Method Summary collapse
-
#add_issue_comment(owner, repo, issue_number, body) ⇒ Object
Add a comment to an existing issue.
-
#create_branch(owner, repo, branch, from_branch: nil) ⇒ Object
Create a new branch in a GitHub repository.
-
#create_issue(owner, repo, title, body: nil, assignees: nil, milestone: nil, labels: nil) ⇒ Object
Create a new issue in a GitHub repository.
-
#create_or_update_file(owner, repo, path, content, message, branch, sha: nil) ⇒ Object
Create or update a single file in a GitHub repository.
-
#create_pull_request(owner, repo, title, head, base, body: nil, draft: nil, maintainer_can_modify: nil) ⇒ Object
Create a new pull request in a GitHub repository.
-
#create_pull_request_review(owner, repo, pull_number, body, event, commit_id: nil, comments: nil) ⇒ Object
Create a review on a pull request.
-
#create_repository(name, description: nil, private: nil, autoinit: nil) ⇒ Object
Create a new GitHub repository in your account.
-
#fork_repository(owner, repo, organization: nil) ⇒ Object
Fork a GitHub repository to your account or specified organization.
-
#get_file_contents(owner, repo, path, branch: nil) ⇒ Object
Get the contents of a file or directory from a GitHub repository.
-
#get_issue(owner, repo, issue_number) ⇒ Object
Get details of a specific issue in a GitHub repository.
-
#get_pull_request(owner, repo, pull_number) ⇒ Object
Get details of a specific pull request.
-
#get_pull_request_comments(owner, repo, pull_number) ⇒ Object
Get the review comments on a pull request.
-
#get_pull_request_files(owner, repo, pull_number) ⇒ Object
Get the list of files changed in a pull request.
-
#get_pull_request_reviews(owner, repo, pull_number) ⇒ Object
Get the reviews on a pull request.
-
#get_pull_request_status(owner, repo, pull_number) ⇒ Object
Get the combined status of all status checks for a pull request.
-
#initialize(leash) ⇒ GithubClient
constructor
Create a new GitHub integration client.
-
#list_commits(owner, repo, sha: nil, page: nil, perpage: nil) ⇒ Object
Get list of commits of a branch in a GitHub repository.
-
#list_issues(owner, repo, direction: nil, labels: nil, page: nil, per_page: nil, since: nil, sort: nil, state: nil) ⇒ Object
List issues in a GitHub repository with filtering options.
-
#list_pull_requests(owner, repo, state: nil, head: nil, base: nil, sort: nil, direction: nil, per_page: nil, page: nil) ⇒ Object
List and filter repository pull requests.
-
#merge_pull_request(owner, repo, pull_number, commit_title: nil, commit_message: nil, merge_method: nil) ⇒ Object
Merge a pull request.
-
#push_files(owner, repo, branch, files, message) ⇒ Object
Push multiple files to a GitHub repository in a single commit.
-
#search_code(q, order: nil, page: nil, per_page: nil) ⇒ Object
Search for code across GitHub repositories.
-
#search_issues(q, order: nil, page: nil, per_page: nil, sort: nil) ⇒ Object
Search for issues and pull requests across GitHub repositories.
-
#search_repositories(query, page: nil, perpage: nil) ⇒ Object
Search for GitHub repositories.
-
#search_users(q, order: nil, page: nil, per_page: nil, sort: nil) ⇒ Object
Search for users on GitHub.
-
#update_issue(owner, repo, issue_number, title: nil, body: nil, assignees: nil, milestone: nil, labels: nil, state: nil) ⇒ Object
Update an existing issue in a GitHub repository.
-
#update_pull_request_branch(owner, repo, pull_number, expected_head_sha: nil) ⇒ Object
Update a pull request branch with the latest changes from the base branch.
Constructor Details
#initialize(leash) ⇒ GithubClient
Create a new GitHub integration client.
11 12 13 |
# File 'lib/leash/integration/github.rb', line 11 def initialize(leash) @leash = leash end |
Instance Method Details
#add_issue_comment(owner, repo, issue_number, body) ⇒ Object
Add a comment to an existing issue
266 267 268 269 270 271 272 273 274 |
# File 'lib/leash/integration/github.rb', line 266 def add_issue_comment(owner, repo, issue_number, body) params = { 'owner' => owner, 'repo' => repo, 'issue_number' => issue_number, 'body' => body }.compact @leash.call('github', 'add_issue_comment', params) end |
#create_branch(owner, repo, branch, from_branch: nil) ⇒ Object
Create a new branch in a GitHub repository
176 177 178 179 180 181 182 183 184 |
# File 'lib/leash/integration/github.rb', line 176 def create_branch(owner, repo, branch, from_branch: nil) params = { 'owner' => owner, 'repo' => repo, 'branch' => branch, 'from_branch' => from_branch }.compact @leash.call('github', 'create_branch', params) end |
#create_issue(owner, repo, title, body: nil, assignees: nil, milestone: nil, labels: nil) ⇒ Object
Create a new issue in a GitHub repository
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/leash/integration/github.rb', line 116 def create_issue(owner, repo, title, body: nil, assignees: nil, milestone: nil, labels: nil) params = { 'owner' => owner, 'repo' => repo, 'title' => title, 'body' => body, 'assignees' => assignees, 'milestone' => milestone, 'labels' => labels }.compact @leash.call('github', 'create_issue', params) end |
#create_or_update_file(owner, repo, path, content, message, branch, sha: nil) ⇒ Object
Create or update a single file in a GitHub repository
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/leash/integration/github.rb', line 25 def create_or_update_file(owner, repo, path, content, , branch, sha: nil) params = { 'owner' => owner, 'repo' => repo, 'path' => path, 'content' => content, 'message' => , 'branch' => branch, 'sha' => sha }.compact @leash.call('github', 'create_or_update_file', params) end |
#create_pull_request(owner, repo, title, head, base, body: nil, draft: nil, maintainer_can_modify: nil) ⇒ Object
Create a new pull request in a GitHub repository
140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/leash/integration/github.rb', line 140 def create_pull_request(owner, repo, title, head, base, body: nil, draft: nil, maintainer_can_modify: nil) params = { 'owner' => owner, 'repo' => repo, 'title' => title, 'body' => body, 'head' => head, 'base' => base, 'draft' => draft, 'maintainer_can_modify' => maintainer_can_modify }.compact @leash.call('github', 'create_pull_request', params) end |
#create_pull_request_review(owner, repo, pull_number, body, event, commit_id: nil, comments: nil) ⇒ Object
Create a review on a pull request
398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'lib/leash/integration/github.rb', line 398 def create_pull_request_review(owner, repo, pull_number, body, event, commit_id: nil, comments: nil) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number, 'commit_id' => commit_id, 'body' => body, 'event' => event, 'comments' => comments }.compact @leash.call('github', 'create_pull_request_review', params) end |
#create_repository(name, description: nil, private: nil, autoinit: nil) ⇒ Object
Create a new GitHub repository in your account
60 61 62 63 64 65 66 67 68 |
# File 'lib/leash/integration/github.rb', line 60 def create_repository(name, description: nil, private: nil, autoinit: nil) params = { 'name' => name, 'description' => description, 'private' => private, 'autoInit' => autoinit }.compact @leash.call('github', 'create_repository', params) end |
#fork_repository(owner, repo, organization: nil) ⇒ Object
Fork a GitHub repository to your account or specified organization
160 161 162 163 164 165 166 167 |
# File 'lib/leash/integration/github.rb', line 160 def fork_repository(owner, repo, organization: nil) params = { 'owner' => owner, 'repo' => repo, 'organization' => organization }.compact @leash.call('github', 'fork_repository', params) end |
#get_file_contents(owner, repo, path, branch: nil) ⇒ Object
Get the contents of a file or directory from a GitHub repository
77 78 79 80 81 82 83 84 85 |
# File 'lib/leash/integration/github.rb', line 77 def get_file_contents(owner, repo, path, branch: nil) params = { 'owner' => owner, 'repo' => repo, 'path' => path, 'branch' => branch }.compact @leash.call('github', 'get_file_contents', params) end |
#get_issue(owner, repo, issue_number) ⇒ Object
Get details of a specific issue in a GitHub repository.
337 338 339 340 341 342 343 344 |
# File 'lib/leash/integration/github.rb', line 337 def get_issue(owner, repo, issue_number) params = { 'owner' => owner, 'repo' => repo, 'issue_number' => issue_number }.compact @leash.call('github', 'get_issue', params) end |
#get_pull_request(owner, repo, pull_number) ⇒ Object
Get details of a specific pull request
352 353 354 355 356 357 358 359 |
# File 'lib/leash/integration/github.rb', line 352 def get_pull_request(owner, repo, pull_number) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number }.compact @leash.call('github', 'get_pull_request', params) end |
#get_pull_request_comments(owner, repo, pull_number) ⇒ Object
Get the review comments on a pull request
485 486 487 488 489 490 491 492 |
# File 'lib/leash/integration/github.rb', line 485 def get_pull_request_comments(owner, repo, pull_number) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number }.compact @leash.call('github', 'get_pull_request_comments', params) end |
#get_pull_request_files(owner, repo, pull_number) ⇒ Object
Get the list of files changed in a pull request
438 439 440 441 442 443 444 445 |
# File 'lib/leash/integration/github.rb', line 438 def get_pull_request_files(owner, repo, pull_number) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number }.compact @leash.call('github', 'get_pull_request_files', params) end |
#get_pull_request_reviews(owner, repo, pull_number) ⇒ Object
Get the reviews on a pull request
500 501 502 503 504 505 506 507 |
# File 'lib/leash/integration/github.rb', line 500 def get_pull_request_reviews(owner, repo, pull_number) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number }.compact @leash.call('github', 'get_pull_request_reviews', params) end |
#get_pull_request_status(owner, repo, pull_number) ⇒ Object
Get the combined status of all status checks for a pull request
453 454 455 456 457 458 459 460 |
# File 'lib/leash/integration/github.rb', line 453 def get_pull_request_status(owner, repo, pull_number) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number }.compact @leash.call('github', 'get_pull_request_status', params) end |
#list_commits(owner, repo, sha: nil, page: nil, perpage: nil) ⇒ Object
Get list of commits of a branch in a GitHub repository
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/leash/integration/github.rb', line 194 def list_commits(owner, repo, sha: nil, page: nil, perpage: nil) params = { 'owner' => owner, 'repo' => repo, 'sha' => sha, 'page' => page, 'perPage' => perpage }.compact @leash.call('github', 'list_commits', params) end |
#list_issues(owner, repo, direction: nil, labels: nil, page: nil, per_page: nil, since: nil, sort: nil, state: nil) ⇒ Object
List issues in a GitHub repository with filtering options
217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/leash/integration/github.rb', line 217 def list_issues(owner, repo, direction: nil, labels: nil, page: nil, per_page: nil, since: nil, sort: nil, state: nil) params = { 'owner' => owner, 'repo' => repo, 'direction' => direction, 'labels' => labels, 'page' => page, 'per_page' => per_page, 'since' => since, 'sort' => sort, 'state' => state }.compact @leash.call('github', 'list_issues', params) end |
#list_pull_requests(owner, repo, state: nil, head: nil, base: nil, sort: nil, direction: nil, per_page: nil, page: nil) ⇒ Object
List and filter repository pull requests
373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/leash/integration/github.rb', line 373 def list_pull_requests(owner, repo, state: nil, head: nil, base: nil, sort: nil, direction: nil, per_page: nil, page: nil) params = { 'owner' => owner, 'repo' => repo, 'state' => state, 'head' => head, 'base' => base, 'sort' => sort, 'direction' => direction, 'per_page' => per_page, 'page' => page }.compact @leash.call('github', 'list_pull_requests', params) end |
#merge_pull_request(owner, repo, pull_number, commit_title: nil, commit_message: nil, merge_method: nil) ⇒ Object
Merge a pull request
420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/leash/integration/github.rb', line 420 def merge_pull_request(owner, repo, pull_number, commit_title: nil, commit_message: nil, merge_method: nil) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number, 'commit_title' => commit_title, 'commit_message' => , 'merge_method' => merge_method }.compact @leash.call('github', 'merge_pull_request', params) end |
#push_files(owner, repo, branch, files, message) ⇒ Object
Push multiple files to a GitHub repository in a single commit
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/leash/integration/github.rb', line 95 def push_files(owner, repo, branch, files, ) params = { 'owner' => owner, 'repo' => repo, 'branch' => branch, 'files' => files, 'message' => }.compact @leash.call('github', 'push_files', params) end |
#search_code(q, order: nil, page: nil, per_page: nil) ⇒ Object
Search for code across GitHub repositories
283 284 285 286 287 288 289 290 291 |
# File 'lib/leash/integration/github.rb', line 283 def search_code(q, order: nil, page: nil, per_page: nil) params = { 'q' => q, 'order' => order, 'page' => page, 'per_page' => per_page }.compact @leash.call('github', 'search_code', params) end |
#search_issues(q, order: nil, page: nil, per_page: nil, sort: nil) ⇒ Object
Search for issues and pull requests across GitHub repositories
301 302 303 304 305 306 307 308 309 310 |
# File 'lib/leash/integration/github.rb', line 301 def search_issues(q, order: nil, page: nil, per_page: nil, sort: nil) params = { 'q' => q, 'order' => order, 'page' => page, 'per_page' => per_page, 'sort' => sort }.compact @leash.call('github', 'search_issues', params) end |
#search_repositories(query, page: nil, perpage: nil) ⇒ Object
Search for GitHub repositories
44 45 46 47 48 49 50 51 |
# File 'lib/leash/integration/github.rb', line 44 def search_repositories(query, page: nil, perpage: nil) params = { 'query' => query, 'page' => page, 'perPage' => perpage }.compact @leash.call('github', 'search_repositories', params) end |
#search_users(q, order: nil, page: nil, per_page: nil, sort: nil) ⇒ Object
Search for users on GitHub
320 321 322 323 324 325 326 327 328 329 |
# File 'lib/leash/integration/github.rb', line 320 def search_users(q, order: nil, page: nil, per_page: nil, sort: nil) params = { 'q' => q, 'order' => order, 'page' => page, 'per_page' => per_page, 'sort' => sort }.compact @leash.call('github', 'search_users', params) end |
#update_issue(owner, repo, issue_number, title: nil, body: nil, assignees: nil, milestone: nil, labels: nil, state: nil) ⇒ Object
Update an existing issue in a GitHub repository
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/leash/integration/github.rb', line 244 def update_issue(owner, repo, issue_number, title: nil, body: nil, assignees: nil, milestone: nil, labels: nil, state: nil) params = { 'owner' => owner, 'repo' => repo, 'issue_number' => issue_number, 'title' => title, 'body' => body, 'assignees' => assignees, 'milestone' => milestone, 'labels' => labels, 'state' => state }.compact @leash.call('github', 'update_issue', params) end |
#update_pull_request_branch(owner, repo, pull_number, expected_head_sha: nil) ⇒ Object
Update a pull request branch with the latest changes from the base branch
469 470 471 472 473 474 475 476 477 |
# File 'lib/leash/integration/github.rb', line 469 def update_pull_request_branch(owner, repo, pull_number, expected_head_sha: nil) params = { 'owner' => owner, 'repo' => repo, 'pull_number' => pull_number, 'expected_head_sha' => expected_head_sha }.compact @leash.call('github', 'update_pull_request_branch', params) end |