Module: Gitlab::Client::MergeRequests

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/merge_requests.rb

Overview

Defines methods related to merge requests.

Instance Method Summary collapse

Instance Method Details

#accept_merge_request(project, id, options = {}) ⇒ Gitlab::ObjectifiedHash

Accepts a merge request.

Examples:

Gitlab.accept_merge_request(5, 42, { merge_commit_message: 'Nice!' })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :merge_commit_message (String)

    Custom merge commit message

Returns:



81
82
83
# File 'lib/gitlab/client/merge_requests.rb', line 81

def accept_merge_request(project, id, options={})
  put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
end

#create_merge_request(project, title, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a merge request.

Examples:

Gitlab.create_merge_request(5, 'New merge request',
  { source_branch: 'source_branch', target_branch: 'target_branch' })
Gitlab.create_merge_request(5, 'New merge request',
  { source_branch: 'source_branch', target_branch: 'target_branch', assignee_id: 42 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • title (String)

    The title of a merge request.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :source_branch (String) — default: required

    The source branch name.

  • :target_branch (String) — default: required

    The target branch name.

  • :assignee_id (Integer) — default: optional

    The ID of a user to assign merge request.

  • :target_project_id (Integer) — default: optional

    The target project ID.

Returns:



48
49
50
51
# File 'lib/gitlab/client/merge_requests.rb', line 48

def create_merge_request(project, title, options={})
  body = { title: title }.merge(options)
  post("/projects/#{url_encode project}/merge_requests", body: body)
end

#create_merge_request_comment(project, id, note) ⇒ Gitlab::ObjectifiedHash

Adds a comment to a merge request.

Examples:

Gitlab.create_merge_request_comment(5, 1, "Awesome merge!")
Gitlab.create_merge_request_comment('gitlab', 1, "Awesome merge!")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

  • note (String)

    The content of a comment.

Returns:



95
96
97
# File 'lib/gitlab/client/merge_requests.rb', line 95

def create_merge_request_comment(project, id, note)
  post("/projects/#{url_encode project}/merge_requests/#{id}/notes", body: { body: note })
end

#delete_merge_request_comment(project, id, note_id) ⇒ Gitlab::ObjectifiedHash

Deletes a comment from a merge request.

Examples:

Gitlab.delete_merge_request_comment(5, 1,2)
Gitlab.delete_merge_request_comment('gitlab', 1, 2)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

  • id (Integer)

    The ID of the merge-request comment

Returns:



124
125
126
# File 'lib/gitlab/client/merge_requests.rb', line 124

def delete_merge_request_comment(project, id, note_id)
  delete("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}")
end

#edit_merge_request_comment(project, id, note_id, note) ⇒ Gitlab::ObjectifiedHash

Adds a comment to a merge request.

Examples:

Gitlab.edit_merge_request_comment(5, 1,2, "Awesome merge!")
Gitlab.edit_merge_request_comment('gitlab', 1, 2, "Awesome merge!")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

  • id (Integer)

    The ID of the merge-request comment

  • note (String)

    The content of a comment.

Returns:



110
111
112
# File 'lib/gitlab/client/merge_requests.rb', line 110

def edit_merge_request_comment(project, id, note_id , note)
  put("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note })
end

#merge_request(project, id) ⇒ Gitlab::ObjectifiedHash

Gets a single merge request.

Examples:

Gitlab.merge_request(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

Returns:



28
29
30
# File 'lib/gitlab/client/merge_requests.rb', line 28

def merge_request(project, id)
  get("/projects/#{url_encode project}/merge_requests/#{id}")
end

#merge_request_changes(project, id) ⇒ Gitlab::ObjectifiedHash

Gets the changes of a merge request.

Examples:

Gitlab.merge_request_changes(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

Returns:



152
153
154
# File 'lib/gitlab/client/merge_requests.rb', line 152

def merge_request_changes(project, id)
  get("/projects/#{url_encode project}/merge_requests/#{id}/changes")
end

#merge_request_closes_issues(project_id, merge_request_iid) ⇒ Object

List issues that will close on merge

Examples:

Gitlab.merge_request_closes_issues(5, 1)

Parameters:

  • project (Integer)

    The ID of a project

  • iid (Integer)

    The internal ID of a merge request



175
176
177
# File 'lib/gitlab/client/merge_requests.rb', line 175

def merge_request_closes_issues(project_id, merge_request_iid)
  get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
end

#merge_request_comments(project, id, options = {}) ⇒ Gitlab::ObjectifiedHash

Gets the comments on a merge request.

Examples:

Gitlab.merge_request_comments(5, 1)
Gitlab.merge_request_comments(5, 1, { per_page: 10, page: 2 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



140
141
142
# File 'lib/gitlab/client/merge_requests.rb', line 140

def merge_request_comments(project, id, options={})
  get("/projects/#{url_encode project}/merge_requests/#{id}/notes", query: options)
end

#merge_request_commits(project, id) ⇒ Array<Gitlab::ObjectifiedHash>

Gets the commits of a merge request.

Examples:

Gitlab.merge_request_commits(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

Returns:



164
165
166
# File 'lib/gitlab/client/merge_requests.rb', line 164

def merge_request_commits(project, id)
  get("/projects/#{url_encode project}/merge_requests/#{id}/commits")
end

#merge_requests(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project merge requests.

Examples:

Gitlab.merge_requests(5)
Gitlab.merge_requests({ per_page: 40 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



16
17
18
# File 'lib/gitlab/client/merge_requests.rb', line 16

def merge_requests(project, options={})
  get("/projects/#{url_encode project}/merge_requests", query: options)
end

#subscribe_to_merge_request(project, id) ⇒ Gitlab::ObjectifiedHash

Subscribes to a merge request.

Examples:

Gitlab.subscribe_to_merge_request(5, 1)
Gitlab.subscribe_to_merge_request('gitlab', 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

Returns:



188
189
190
# File 'lib/gitlab/client/merge_requests.rb', line 188

def subscribe_to_merge_request(project, id)
  post("/projects/#{url_encode project}/merge_requests/#{id}/subscribe")
end

#unsubscribe_from_merge_request(project, id) ⇒ Gitlab::ObjectifiedHash

Unsubscribes from a merge request.

Examples:

Gitlab.unsubscribe_from_merge_request(5, 1)
Gitlab.unsubscribe_from_merge_request('gitlab', 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

Returns:



201
202
203
# File 'lib/gitlab/client/merge_requests.rb', line 201

def unsubscribe_from_merge_request(project, id)
  post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe")
end

#update_merge_request(project, id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates a merge request.

Examples:

Gitlab.update_merge_request(5, 42, { title: 'New title' })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a merge request.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :title (String)

    The title of a merge request.

  • :source_branch (String)

    The source branch name.

  • :target_branch (String)

    The target branch name.

  • :assignee_id (Integer)

    The ID of a user to assign merge request.

  • :state_event (String)

    New state (close|reopen|merge).

Returns:



67
68
69
# File 'lib/gitlab/client/merge_requests.rb', line 67

def update_merge_request(project, id, options={})
  put("/projects/#{url_encode project}/merge_requests/#{id}", body: options)
end