Class: Geet::Gitlab::PR

Inherits:
Object
  • Object
show all
Defined in:
lib/geet/gitlab/pr.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, api_interface, title, link) ⇒ PR

Returns a new instance of PR.



8
9
10
11
12
13
# File 'lib/geet/gitlab/pr.rb', line 8

def initialize(number, api_interface, title, link)
  @number = number
  @api_interface = api_interface
  @title = title
  @link = link
end

Instance Attribute Details

Returns the value of attribute link.



6
7
8
# File 'lib/geet/gitlab/pr.rb', line 6

def link
  @link
end

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'lib/geet/gitlab/pr.rb', line 6

def number
  @number
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/geet/gitlab/pr.rb', line 6

def title
  @title
end

Class Method Details

.list(api_interface, milestone: nil, assignee: nil, owner: nil, head: nil) ⇒ Object

owner: required only for API compatibility. it’s not required; if passed, it’s only checked

against the API path to make sure it's correct.

See docs.gitlab.com/ee/api/merge_requests.html#list-merge-requests



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/geet/gitlab/pr.rb', line 20

def self.list(api_interface, milestone: nil, assignee: nil, owner: nil, head: nil)
  api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/merge_requests"

  check_list_owner!(api_interface, owner) if owner

  request_params = {}
  request_params[:assignee_id] = assignee.id if assignee
  request_params[:milestone] = milestone.title if milestone
  request_params[:source_branch] = head if head

  response = api_interface.send_request(api_path, params: request_params, multipage: true)

  response.map do |issue_data, result|
    number = issue_data.fetch('iid')
    title = issue_data.fetch('title')
    link = issue_data.fetch('web_url')

    new(number, api_interface, title, link)
  end
end

Instance Method Details

#mergeObject



43
44
45
46
47
# File 'lib/geet/gitlab/pr.rb', line 43

def merge
  api_path = "projects/#{@api_interface.path_with_namespace(encoded: true)}/merge_requests/#{number}/merge"

  @api_interface.send_request(api_path, http_method: :put)
end