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

Options Hash (options):

  • :merge_commit_message (String)

    Custom merge commit message


120
121
122
# File 'lib/gitlab/client/merge_requests.rb', line 120

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

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.

  • :labels (String) — default: optional

    Labels as a comma-separated list.


87
88
89
90
# File 'lib/gitlab/client/merge_requests.rb', line 87

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_discussion(project, merge_request_id, options = {}) ⇒ Gitlab::ObjectifiedHash

Create new merge request discussion

Examples:

Gitlab.create_merge_request_discussion(5, 1, body: 'discuss')
Gitlab.create_merge_request_discussion('gitlab', 1, body: 'discuss')

234
235
236
# File 'lib/gitlab/client/merge_requests.rb', line 234

def create_merge_request_discussion(project, merge_request_id, options = {})
  post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", body: options)
end

#create_merge_request_discussion_note(project, merge_request_id, discussion_id, options) ⇒ Gitlab::ObjectifiedHash

Add note to existing merge request discussion

Examples:

Gitlab.create_merge_request_discussion_note(5, 1, 1, note_id: 1, body: 'note')
Gitlab.create_merge_request_discussion_note('gitlab', 1, 1, note_id: 1, body: 'note')

Options Hash (options):

  • :note_id (Integer)

    The ID of a discussion note.

  • :body (String)

    The content of a discussion.

  • :created_at (String)

    Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z.


266
267
268
# File 'lib/gitlab/client/merge_requests.rb', line 266

def create_merge_request_discussion_note(project, merge_request_id, discussion_id, options)
  post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes", body: options)
end

#delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id) ⇒ Gitlab::ObjectifiedHash

Delete a merge request discussion note

Examples:

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

297
298
299
# File 'lib/gitlab/client/merge_requests.rb', line 297

def delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id)
  delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
end

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

Gets a single merge request.

Examples:

Gitlab.merge_request(5, 36)

42
43
44
# File 'lib/gitlab/client/merge_requests.rb', line 42

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)

132
133
134
# File 'lib/gitlab/client/merge_requests.rb', line 132

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)

155
156
157
# File 'lib/gitlab/client/merge_requests.rb', line 155

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

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

Gets the commits of a merge request.

Examples:

Gitlab.merge_request_commits(5, 1)

144
145
146
# File 'lib/gitlab/client/merge_requests.rb', line 144

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

#merge_request_diff_version(project, merge_request_id, version_id) ⇒ Gitlab::ObjectifiedHash

Gets the diff a single merge request diff version\

Examples:

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

322
323
324
# File 'lib/gitlab/client/merge_requests.rb', line 322

def merge_request_diff_version(project, merge_request_id, version_id)
  get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions/#{version_id}")
end

#merge_request_diff_versions(project, merge_request_id) ⇒ Gitlab::ObjectifiedHash

Gets a list of merge request diff versions

Examples:

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

309
310
311
# File 'lib/gitlab/client/merge_requests.rb', line 309

def merge_request_diff_versions(project, merge_request_id)
  get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions")
end

#merge_request_discussion(project, merge_request_id, discussion_id) ⇒ Gitlab::ObjectifiedHash

Get single merge request discussion

Examples:

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

206
207
208
# File 'lib/gitlab/client/merge_requests.rb', line 206

def merge_request_discussion(project, merge_request_id, discussion_id)
  get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}")
end

#merge_request_discussions(project, merge_request_id) ⇒ Gitlab::ObjectifiedHash

List project merge request discussions

Examples:

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

193
194
195
# File 'lib/gitlab/client/merge_requests.rb', line 193

def merge_request_discussions(project, merge_request_id)
  get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions")
end

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

Get a list of merge request participants.

Examples:

Gitlab.merge_request_participants(5, 36)

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

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

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

Gets a list of merge request pipelines.

Examples:

Gitlab.merge_request_pipelines(5, 36)

54
55
56
# File 'lib/gitlab/client/merge_requests.rb', line 54

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

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

Gets a list of project merge requests.

Examples:

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

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.


30
31
32
# File 'lib/gitlab/client/merge_requests.rb', line 30

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

#resolve_merge_request_discussion(project, merge_request_id, discussion_id, options) ⇒ Gitlab::ObjectifiedHash

Resolve a merge request discussion

Examples:

Gitlab.resolve_merge_request_discussion(5, 1, 1, true)
Gitlab.resolve_merge_request_discussion('gitlab', 1, 1, false)

Options Hash (options):

  • :resolved (Boolean)

    Resolve/unresolve the discussion.


249
250
251
# File 'lib/gitlab/client/merge_requests.rb', line 249

def resolve_merge_request_discussion(project, merge_request_id, discussion_id, options)
  put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}", body: 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)

168
169
170
# File 'lib/gitlab/client/merge_requests.rb', line 168

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)

181
182
183
# File 'lib/gitlab/client/merge_requests.rb', line 181

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

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


106
107
108
# File 'lib/gitlab/client/merge_requests.rb', line 106

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

#update_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id, options) ⇒ Gitlab::ObjectifiedHash

Modify an existing merge request discussion note

Examples:

Gitlab.update_merge_request_discussion_note(5, 1, 1, 1, body: 'note')
Gitlab.update_merge_request_discussion_note('gitlab', 1, 1, 1, body: 'note')

Options Hash (options):

  • :body (String)

    The content of a discussion.

  • :resolved (Boolean)

    Resolve/unresolve the note.


283
284
285
# File 'lib/gitlab/client/merge_requests.rb', line 283

def update_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id, options)
  put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}", body: options)
end

#user_merge_requests(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of all of the merge requests the authenticated user has access to.

Examples:

Gitlab.user_merge_requests
Gitlab.user_merge_requests(state: :opened, scope: :all)

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

def user_merge_requests(options = {})
  get('/merge_requests', query: options)
end