Class: Geet::Github::PR
- Inherits:
-
AbstractIssue
- Object
- AbstractIssue
- Geet::Github::PR
- Defined in:
- lib/geet/github/pr.rb
Instance Attribute Summary
Attributes inherited from AbstractIssue
Class Method Summary collapse
- .create(title, description, head, api_interface, base: nil) ⇒ Object
- .list(api_interface, milestone: nil, assignee: nil, head: nil) ⇒ Object
Instance Method Summary collapse
Methods inherited from AbstractIssue
#add_labels, #assign_users, #edit, #initialize
Constructor Details
This class inherits a constructor from Geet::Github::AbstractIssue
Class Method Details
.create(title, description, head, api_interface, base: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/geet/github/pr.rb', line 11 def self.create(title, description, head, api_interface, base: nil) api_path = 'pulls' base ||= 'master' if api_interface.upstream? authenticated_user = Geet::Github::User.authenticated(api_interface).username head = "#{authenticated_user}:#{head}" end request_data = { title: title, body: description, head: head, base: base } response = api_interface.send_request(api_path, data: request_data) number, title, link = response.fetch_values('number', 'title', 'html_url') new(number, api_interface, title, link) end |
.list(api_interface, milestone: nil, assignee: nil, head: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/geet/github/pr.rb', line 31 def self.list(api_interface, milestone: nil, assignee: nil, head: nil) check_list_params!(milestone, assignee, head) if head api_path = 'pulls' request_params = { head: head } response = api_interface.send_request(api_path, params: request_params, multipage: true) response.map do |issue_data| number = issue_data.fetch('number') title = issue_data.fetch('title') link = issue_data.fetch('html_url') new(number, api_interface, title, link) end else super(api_interface, milestone: milestone, assignee: assignee) do |issue_data| issue_data.key?('pull_request') end end end |
Instance Method Details
#merge ⇒ Object
56 57 58 59 60 |
# File 'lib/geet/github/pr.rb', line 56 def merge api_path = "pulls/#{number}/merge" @api_interface.send_request(api_path, http_method: :put) end |
#request_review(reviewers) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/geet/github/pr.rb', line 62 def request_review(reviewers) api_path = "pulls/#{number}/requested_reviewers" request_data = { reviewers: reviewers } @api_interface.send_request(api_path, data: request_data) end |