module Gitlab::Client::MergeRequests

Defines methods related to merge requests. @see docs.gitlab.com/ce/api/merge_requests.html

Public Instance Methods

accept_merge_request(project, id, options={}) click to toggle source

Accepts a merge request.

@example

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

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @param [Hash] options A customizable set of options. @option options [String] :merge_commit_message Custom merge commit message @return [Gitlab::ObjectifiedHash] Information about updated merge request.

# File lib/gitlab/client/merge_requests.rb, line 81
def accept_merge_request(project, id, options={})
  put("/projects/#{project}/merge_request/#{id}/merge", body: options)
end
create_merge_request(project, title, options={}) click to toggle source

Creates a merge request.

@example

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 })

@param [Integer] project The ID of a project. @param [String] title The title of a merge request. @param [Hash] options A customizable set of options. @option options [String] :source_branch (required) The source branch name. @option options [String] :target_branch (required) The target branch name. @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request. @option options [Integer] :target_project_id (optional) The target project ID. @return [Gitlab::ObjectifiedHash] Information about created merge request.

# File lib/gitlab/client/merge_requests.rb, line 48
def create_merge_request(project, title, options={})
  body = { title: title }.merge(options)
  post("/projects/#{project}/merge_requests", body: body)
end
create_merge_request_comment(project, id, note) click to toggle source

Adds a comment to a merge request.

@example

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

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @param [String] note The content of a comment. @return [Gitlab::ObjectifiedHash] Information about created merge request comment.

# File lib/gitlab/client/merge_requests.rb, line 95
def create_merge_request_comment(project, id, note)
  post("/projects/#{project}/merge_requests/#{id}/notes", body: { body: note })
end
delete_merge_request_comment(project, id, note_id) click to toggle source

Deletes a comment from a merge request.

@example

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

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @param [Integer] id The ID of the merge-request comment @return [Gitlab::ObjectifiedHash] Information about created merge request comment.

# File lib/gitlab/client/merge_requests.rb, line 124
def delete_merge_request_comment(project, id, note_id)
  delete("/projects/#{project}/merge_requests/#{id}/notes/#{note_id}")
end
edit_merge_request_comment(project, id, note_id , note) click to toggle source

Adds a comment to a merge request.

@example

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

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @param [Integer] id The ID of the merge-request comment @param [String] note The content of a comment. @return [Gitlab::ObjectifiedHash] Information about created merge request comment.

# File lib/gitlab/client/merge_requests.rb, line 110
def edit_merge_request_comment(project, id, note_id , note)
  put("/projects/#{project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note })
end
merge_request(project, id) click to toggle source

Gets a single merge request.

@example

Gitlab.merge_request(5, 36)

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @return <Gitlab::ObjectifiedHash]

# File lib/gitlab/client/merge_requests.rb, line 28
def merge_request(project, id)
  get("/projects/#{project}/merge_request/#{id}")
end
merge_request_changes(project, id) click to toggle source

Gets the changes of a merge request.

@example

Gitlab.merge_request_changes(5, 1)

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @return [Gitlab::ObjectifiedHash] The merge request's changes.

# File lib/gitlab/client/merge_requests.rb, line 152
def merge_request_changes(project, id)
  get("/projects/#{project}/merge_request/#{id}/changes")
end
merge_request_comments(project, id, options={}) click to toggle source

Gets the comments on a merge request.

@example

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

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @param [Hash] options A customizable set of options. @option options [Integer] :page The page number. @option options [Integer] :per_page The number of results per page. @return [Gitlab::ObjectifiedHash] The merge request's comments.

# File lib/gitlab/client/merge_requests.rb, line 140
def merge_request_comments(project, id, options={})
  get("/projects/#{project}/merge_requests/#{id}/notes", query: options)
end
merge_request_commits(project, id) click to toggle source

Gets the commits of a merge request.

@example

Gitlab.merge_request_commits(5, 1)

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @return [Array<Gitlab::ObjectifiedHash>] The merge request's commits.

# File lib/gitlab/client/merge_requests.rb, line 164
def merge_request_commits(project, id)
  get("/projects/#{project}/merge_request/#{id}/commits")
end
merge_requests(project, options={}) click to toggle source

Gets a list of project merge requests.

@example

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

@param [Integer] project The ID of a project. @param [Hash] options A customizable set of options. @option options [Integer] :page The page number. @option options [Integer] :per_page The number of results per page. @return [Array<Gitlab::ObjectifiedHash>]

# File lib/gitlab/client/merge_requests.rb, line 16
def merge_requests(project, options={})
  get("/projects/#{project}/merge_requests", query: options)
end
update_merge_request(project, id, options={}) click to toggle source

Updates a merge request.

@example

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

@param [Integer] project The ID of a project. @param [Integer] id The ID of a merge request. @param [Hash] options A customizable set of options. @option options [String] :title The title of a merge request. @option options [String] :source_branch The source branch name. @option options [String] :target_branch The target branch name. @option options [Integer] :assignee_id The ID of a user to assign merge request. @option options [String] :state_event New state (close|reopen|merge). @return [Gitlab::ObjectifiedHash] Information about updated merge request.

# File lib/gitlab/client/merge_requests.rb, line 67
def update_merge_request(project, id, options={})
  put("/projects/#{project}/merge_request/#{id}", body: options)
end