gitlab 4.5.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/stale.yml +18 -0
  3. data/.rubocop_todo.yml +46 -0
  4. data/Gemfile +2 -0
  5. data/README.md +22 -22
  6. data/Rakefile +3 -5
  7. data/bin/console +1 -0
  8. data/exe/gitlab +5 -1
  9. data/gitlab.gemspec +9 -6
  10. data/lib/gitlab.rb +6 -3
  11. data/lib/gitlab/api.rb +5 -3
  12. data/lib/gitlab/cli.rb +11 -5
  13. data/lib/gitlab/cli_helpers.rb +31 -22
  14. data/lib/gitlab/client.rb +7 -8
  15. data/lib/gitlab/client/access_requests.rb +100 -93
  16. data/lib/gitlab/client/award_emojis.rb +127 -127
  17. data/lib/gitlab/client/boards.rb +82 -82
  18. data/lib/gitlab/client/branches.rb +89 -89
  19. data/lib/gitlab/client/build_variables.rb +117 -117
  20. data/lib/gitlab/client/builds.rb +98 -98
  21. data/lib/gitlab/client/commits.rb +154 -154
  22. data/lib/gitlab/client/deployments.rb +29 -29
  23. data/lib/gitlab/client/environments.rb +80 -80
  24. data/lib/gitlab/client/events.rb +54 -54
  25. data/lib/gitlab/client/group_milestones.rb +85 -86
  26. data/lib/gitlab/client/groups.rb +178 -178
  27. data/lib/gitlab/client/issues.rb +195 -196
  28. data/lib/gitlab/client/jobs.rb +150 -150
  29. data/lib/gitlab/client/keys.rb +14 -14
  30. data/lib/gitlab/client/labels.rb +79 -79
  31. data/lib/gitlab/client/merge_request_approvals.rb +102 -102
  32. data/lib/gitlab/client/merge_requests.rb +281 -256
  33. data/lib/gitlab/client/milestones.rb +85 -85
  34. data/lib/gitlab/client/namespaces.rb +18 -18
  35. data/lib/gitlab/client/notes.rb +260 -260
  36. data/lib/gitlab/client/pipeline_schedules.rb +123 -123
  37. data/lib/gitlab/client/pipeline_triggers.rb +93 -93
  38. data/lib/gitlab/client/pipelines.rb +62 -62
  39. data/lib/gitlab/client/projects.rb +526 -505
  40. data/lib/gitlab/client/repositories.rb +68 -55
  41. data/lib/gitlab/client/repository_files.rb +103 -103
  42. data/lib/gitlab/client/runners.rb +113 -115
  43. data/lib/gitlab/client/services.rb +46 -45
  44. data/lib/gitlab/client/sidekiq.rb +32 -32
  45. data/lib/gitlab/client/snippets.rb +86 -86
  46. data/lib/gitlab/client/system_hooks.rb +57 -57
  47. data/lib/gitlab/client/tags.rb +87 -88
  48. data/lib/gitlab/client/todos.rb +41 -41
  49. data/lib/gitlab/client/users.rb +242 -228
  50. data/lib/gitlab/client/versions.rb +16 -0
  51. data/lib/gitlab/configuration.rb +7 -5
  52. data/lib/gitlab/error.rb +3 -1
  53. data/lib/gitlab/file_response.rb +4 -2
  54. data/lib/gitlab/help.rb +9 -9
  55. data/lib/gitlab/objectified_hash.rb +5 -4
  56. data/lib/gitlab/page_links.rb +9 -7
  57. data/lib/gitlab/paginated_response.rb +14 -4
  58. data/lib/gitlab/request.rb +8 -5
  59. data/lib/gitlab/shell.rb +6 -4
  60. data/lib/gitlab/shell_history.rb +7 -5
  61. data/lib/gitlab/version.rb +3 -1
  62. metadata +8 -5
@@ -1,110 +1,110 @@
1
- class Gitlab::Client
2
- # Defines methods related to MR Approvals.
3
- # @see https://docs.gitlab.com/ee/api/merge_request_approvals.html
4
- module MergeRequestApprovals
5
- # Gets MR Approval Configuration for a project
6
- #
7
- # @example
8
- # Gitlab.project_merge_request_approvals(1)
9
- #
10
- # @param [Integer] project The ID of a project.
11
- # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
12
- def project_merge_request_approvals(project)
13
- get("/projects/#{url_encode project}/approvals")
14
- end
1
+ # frozen_string_literal: true
15
2
 
16
- # Change MR Approval Configuration for a project
17
- #
18
- # @example
19
- # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3})
20
- # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, reset_approvals_on_push: true})
21
- # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, disable_overriding_approvers_per_merge_request: false})
22
- #
23
- # @param [Integer] project(required) The ID of a project.
24
- # @option options [Integer] :approvals_before_merge(optional) How many approvals are required before an MR can be merged
25
- # @option options [Boolean] :reset_approvals_on_push(optional) Reset approvals on a new push
26
- # @option options [Boolean] :disable_overriding_approvers_per_merge_request(optional) Allow/Disallow overriding approvers per MR
27
- # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
28
- def edit_project_merge_request_approvals(project, options = {})
29
- post("/projects/#{url_encode project}/approvals", body: options)
30
- end
3
+ # Defines methods related to MR Approvals.
4
+ # @see https://docs.gitlab.com/ee/api/merge_request_approvals.html
5
+ module MergeRequestApprovals
6
+ # Gets MR Approval Configuration for a project
7
+ #
8
+ # @example
9
+ # Gitlab.project_merge_request_approvals(1)
10
+ #
11
+ # @param [Integer] project The ID of a project.
12
+ # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
13
+ def project_merge_request_approvals(project)
14
+ get("/projects/#{url_encode project}/approvals")
15
+ end
16
+
17
+ # Change MR Approval Configuration for a project
18
+ #
19
+ # @example
20
+ # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3})
21
+ # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, reset_approvals_on_push: true})
22
+ # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, disable_overriding_approvers_per_merge_request: false})
23
+ #
24
+ # @param [Integer] project(required) The ID of a project.
25
+ # @option options [Integer] :approvals_before_merge(optional) How many approvals are required before an MR can be merged
26
+ # @option options [Boolean] :reset_approvals_on_push(optional) Reset approvals on a new push
27
+ # @option options [Boolean] :disable_overriding_approvers_per_merge_request(optional) Allow/Disallow overriding approvers per MR
28
+ # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
29
+ def edit_project_merge_request_approvals(project, options = {})
30
+ post("/projects/#{url_encode project}/approvals", body: options)
31
+ end
31
32
 
32
- # Change allowed approvers and approver groups for a project
33
- #
34
- # @example
35
- # Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
36
- #
37
- # @param [Integer] project(required) The ID of a project.
38
- # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
39
- # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
40
- # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
41
- def edit_project_approvers(project, options = {})
42
- put("/projects/#{url_encode project}/approvals", body: options)
43
- end
33
+ # Change allowed approvers and approver groups for a project
34
+ #
35
+ # @example
36
+ # Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
37
+ #
38
+ # @param [Integer] project(required) The ID of a project.
39
+ # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
40
+ # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
41
+ # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
42
+ def edit_project_approvers(project, options = {})
43
+ put("/projects/#{url_encode project}/approvals", body: options)
44
+ end
44
45
 
45
- # Get Configuration for approvals on a specific Merge Request.
46
- #
47
- # @example
48
- # Gitlab.merge_request_approvals(1, 5)
49
- #
50
- # @param [Integer] project(required) The ID of a project.
51
- # @param [Integer] merge_request(required) The IID of a merge_request.
52
- # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the merge request
53
- def merge_request_approvals(project, merge_request)
54
- get("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals")
55
- end
46
+ # Get Configuration for approvals on a specific Merge Request.
47
+ #
48
+ # @example
49
+ # Gitlab.merge_request_approvals(1, 5)
50
+ #
51
+ # @param [Integer] project(required) The ID of a project.
52
+ # @param [Integer] merge_request(required) The IID of a merge_request.
53
+ # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the merge request
54
+ def merge_request_approvals(project, merge_request)
55
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals")
56
+ end
56
57
 
57
- # Change configuration for approvals on a specific merge request.
58
- #
59
- # @example
60
- # Gitlab.edit_merge_request_approvals(1, 5, approvals_required: 2)
61
- #
62
- # @param [Integer] project(required) The ID of a project.
63
- # @param [Integer] merge_request(required) The IID of a merge_request.
64
- # @option options [Integer] :approvals_required(required) Approvals required before MR can be merged
65
- # @return [Gitlab::ObjectifiedHash] Updated MR approval configuration information about the merge request
66
- def edit_merge_request_approvals(project, merge_request, options = {})
67
- post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
68
- end
58
+ # Change configuration for approvals on a specific merge request.
59
+ #
60
+ # @example
61
+ # Gitlab.edit_merge_request_approvals(1, 5, approvals_required: 2)
62
+ #
63
+ # @param [Integer] project(required) The ID of a project.
64
+ # @param [Integer] merge_request(required) The IID of a merge_request.
65
+ # @option options [Integer] :approvals_required(required) Approvals required before MR can be merged
66
+ # @return [Gitlab::ObjectifiedHash] Updated MR approval configuration information about the merge request
67
+ def edit_merge_request_approvals(project, merge_request, options = {})
68
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
69
+ end
69
70
 
70
- # Change allowed approvers and approver groups for a merge request
71
- #
72
- # @example
73
- # Gitlab.edit_merge_request_approvers(1, 5, {approver_ids: [5], approver_groups: [1]})
74
- #
75
- # @param [Integer] project(required) The ID of a project.
76
- # @param [Integer] merge_request(required) The IID of a merge_request.
77
- # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
78
- # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
79
- # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
80
- def edit_merge_request_approvers(project, merge_request, options = {})
81
- put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
82
- end
71
+ # Change allowed approvers and approver groups for a merge request
72
+ #
73
+ # @example
74
+ # Gitlab.edit_merge_request_approvers(1, 5, {approver_ids: [5], approver_groups: [1]})
75
+ #
76
+ # @param [Integer] project(required) The ID of a project.
77
+ # @param [Integer] merge_request(required) The IID of a merge_request.
78
+ # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
79
+ # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
80
+ # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
81
+ def edit_merge_request_approvers(project, merge_request, options = {})
82
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
83
+ end
83
84
 
84
- # Approve a merge request
85
- #
86
- # @example
87
- # Gitlab.approve_merge_request(1, 5)
88
- # Gitlab.approve_merge_request(1, 5, sha: 'fe678da')
89
- #
90
- # @param [Integer] project(required) The ID of a project.
91
- # @param [Integer] merge_request(required) The IID of a merge request.
92
- # @option options [String] :sha(optional) The HEAD of the MR
93
- # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
94
- def approve_merge_request(project, merge_request, options = {})
95
- post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approve", body: options)
96
- end
85
+ # Approve a merge request
86
+ #
87
+ # @example
88
+ # Gitlab.approve_merge_request(1, 5)
89
+ # Gitlab.approve_merge_request(1, 5, sha: 'fe678da')
90
+ #
91
+ # @param [Integer] project(required) The ID of a project.
92
+ # @param [Integer] merge_request(required) The IID of a merge request.
93
+ # @option options [String] :sha(optional) The HEAD of the MR
94
+ # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
95
+ def approve_merge_request(project, merge_request, options = {})
96
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approve", body: options)
97
+ end
97
98
 
98
- # Unapprove a merge request
99
- #
100
- # @example
101
- # Gitlab.unapprove_merge_request(1, 5)
102
- #
103
- # @param [Integer] project(required) The ID of a project.
104
- # @param [Integer] merge_request(required) The IID of a merge request.
105
- # @return [void] This API call returns an empty response body.
106
- def unapprove_merge_request(project, merge_request)
107
- post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove")
108
- end
99
+ # Unapprove a merge request
100
+ #
101
+ # @example
102
+ # Gitlab.unapprove_merge_request(1, 5)
103
+ #
104
+ # @param [Integer] project(required) The ID of a project.
105
+ # @param [Integer] merge_request(required) The IID of a merge request.
106
+ # @return [void] This API call returns an empty response body.
107
+ def unapprove_merge_request(project, merge_request)
108
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove")
109
109
  end
110
- end
110
+ end
@@ -1,275 +1,300 @@
1
- class Gitlab::Client
2
- # Defines methods related to merge requests.
3
- # @see https://docs.gitlab.com/ce/api/merge_requests.html
4
- module MergeRequests
5
- # Gets a list of all of the merge requests the authenticated user has access to.
6
- #
7
- # @example
8
- # Gitlab.user_merge_requests
9
- # Gitlab.user_merge_requests(state: :opened, scope: :all)
10
- #
11
- # @param [Hash] options A customizable set of options.
12
- # @return [Array<Gitlab::ObjectifiedHash>]
13
- def user_merge_requests(options = {})
14
- get('/merge_requests', query: options)
15
- end
1
+ # frozen_string_literal: true
16
2
 
17
- # Gets a list of project merge requests.
18
- #
19
- # @example
20
- # Gitlab.merge_requests(5)
21
- # Gitlab.merge_requests(5, { per_page: 40 })
22
- #
23
- # @param [Integer, String] project The ID or name of a project.
24
- # @param [Hash] options A customizable set of options.
25
- # @option options [Integer] :page The page number.
26
- # @option options [Integer] :per_page The number of results per page.
27
- # @return [Array<Gitlab::ObjectifiedHash>]
28
- def merge_requests(project, options={})
29
- get("/projects/#{url_encode project}/merge_requests", query: options)
30
- end
3
+ # Defines methods related to merge requests.
4
+ # @see https://docs.gitlab.com/ce/api/merge_requests.html
5
+ module MergeRequests
6
+ # Gets a list of all of the merge requests the authenticated user has access to.
7
+ #
8
+ # @example
9
+ # Gitlab.user_merge_requests
10
+ # Gitlab.user_merge_requests(state: :opened, scope: :all)
11
+ #
12
+ # @param [Hash] options A customizable set of options.
13
+ # @return [Array<Gitlab::ObjectifiedHash>]
14
+ def user_merge_requests(options = {})
15
+ get('/merge_requests', query: options)
16
+ end
17
+
18
+ # Gets a list of project merge requests.
19
+ #
20
+ # @example
21
+ # Gitlab.merge_requests(5)
22
+ # Gitlab.merge_requests(5, { per_page: 40 })
23
+ #
24
+ # @param [Integer, String] project The ID or name of a project.
25
+ # @param [Hash] options A customizable set of options.
26
+ # @option options [Integer] :page The page number.
27
+ # @option options [Integer] :per_page The number of results per page.
28
+ # @return [Array<Gitlab::ObjectifiedHash>]
29
+ def merge_requests(project, options = {})
30
+ get("/projects/#{url_encode project}/merge_requests", query: options)
31
+ end
31
32
 
32
- # Gets a single merge request.
33
- #
34
- # @example
35
- # Gitlab.merge_request(5, 36)
36
- #
37
- # @param [Integer, String] project The ID or name of a project.
38
- # @param [Integer] id The ID of a merge request.
39
- # @return <Gitlab::ObjectifiedHash]
40
- def merge_request(project, id)
41
- get("/projects/#{url_encode project}/merge_requests/#{id}")
42
- end
33
+ # Gets a single merge request.
34
+ #
35
+ # @example
36
+ # Gitlab.merge_request(5, 36)
37
+ #
38
+ # @param [Integer, String] project The ID or name of a project.
39
+ # @param [Integer] id The ID of a merge request.
40
+ # @return <Gitlab::ObjectifiedHash]
41
+ def merge_request(project, id)
42
+ get("/projects/#{url_encode project}/merge_requests/#{id}")
43
+ end
43
44
 
44
- # Creates a merge request.
45
- #
46
- # @example
47
- # Gitlab.create_merge_request(5, 'New merge request',
48
- # { source_branch: 'source_branch', target_branch: 'target_branch' })
49
- # Gitlab.create_merge_request(5, 'New merge request',
50
- # { source_branch: 'source_branch', target_branch: 'target_branch', assignee_id: 42 })
51
- #
52
- # @param [Integer, String] project The ID or name of a project.
53
- # @param [String] title The title of a merge request.
54
- # @param [Hash] options A customizable set of options.
55
- # @option options [String] :source_branch (required) The source branch name.
56
- # @option options [String] :target_branch (required) The target branch name.
57
- # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
58
- # @option options [Integer] :target_project_id (optional) The target project ID.
59
- # @option options [String] :labels (optional) Labels as a comma-separated list.
60
- # @return [Gitlab::ObjectifiedHash] Information about created merge request.
61
- def create_merge_request(project, title, options={})
62
- body = { title: title }.merge(options)
63
- post("/projects/#{url_encode project}/merge_requests", body: body)
64
- end
45
+ # Creates a merge request.
46
+ #
47
+ # @example
48
+ # Gitlab.create_merge_request(5, 'New merge request',
49
+ # { source_branch: 'source_branch', target_branch: 'target_branch' })
50
+ # Gitlab.create_merge_request(5, 'New merge request',
51
+ # { source_branch: 'source_branch', target_branch: 'target_branch', assignee_id: 42 })
52
+ #
53
+ # @param [Integer, String] project The ID or name of a project.
54
+ # @param [String] title The title of a merge request.
55
+ # @param [Hash] options A customizable set of options.
56
+ # @option options [String] :source_branch (required) The source branch name.
57
+ # @option options [String] :target_branch (required) The target branch name.
58
+ # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
59
+ # @option options [Integer] :target_project_id (optional) The target project ID.
60
+ # @option options [String] :labels (optional) Labels as a comma-separated list.
61
+ # @return [Gitlab::ObjectifiedHash] Information about created merge request.
62
+ def create_merge_request(project, title, options = {})
63
+ body = { title: title }.merge(options)
64
+ post("/projects/#{url_encode project}/merge_requests", body: body)
65
+ end
65
66
 
66
- # Updates a merge request.
67
- #
68
- # @example
69
- # Gitlab.update_merge_request(5, 42, { title: 'New title' })
70
- #
71
- # @param [Integer, String] project The ID or name of a project.
72
- # @param [Integer] id The ID of a merge request.
73
- # @param [Hash] options A customizable set of options.
74
- # @option options [String] :title The title of a merge request.
75
- # @option options [String] :source_branch The source branch name.
76
- # @option options [String] :target_branch The target branch name.
77
- # @option options [Integer] :assignee_id The ID of a user to assign merge request.
78
- # @option options [String] :state_event New state (close|reopen|merge).
79
- # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
80
- def update_merge_request(project, id, options={})
81
- put("/projects/#{url_encode project}/merge_requests/#{id}", body: options)
82
- end
67
+ # Updates a merge request.
68
+ #
69
+ # @example
70
+ # Gitlab.update_merge_request(5, 42, { title: 'New title' })
71
+ #
72
+ # @param [Integer, String] project The ID or name of a project.
73
+ # @param [Integer] id The ID of a merge request.
74
+ # @param [Hash] options A customizable set of options.
75
+ # @option options [String] :title The title of a merge request.
76
+ # @option options [String] :source_branch The source branch name.
77
+ # @option options [String] :target_branch The target branch name.
78
+ # @option options [Integer] :assignee_id The ID of a user to assign merge request.
79
+ # @option options [String] :state_event New state (close|reopen|merge).
80
+ # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
81
+ def update_merge_request(project, id, options = {})
82
+ put("/projects/#{url_encode project}/merge_requests/#{id}", body: options)
83
+ end
83
84
 
84
- # Accepts a merge request.
85
- #
86
- # @example
87
- # Gitlab.accept_merge_request(5, 42, { merge_commit_message: 'Nice!' })
88
- #
89
- # @param [Integer, String] project The ID or name of a project.
90
- # @param [Integer] id The ID of a merge request.
91
- # @param [Hash] options A customizable set of options.
92
- # @option options [String] :merge_commit_message Custom merge commit message
93
- # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
94
- def accept_merge_request(project, id, options={})
95
- put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
96
- end
85
+ # Accepts a merge request.
86
+ #
87
+ # @example
88
+ # Gitlab.accept_merge_request(5, 42, { merge_commit_message: 'Nice!' })
89
+ #
90
+ # @param [Integer, String] project The ID or name of a project.
91
+ # @param [Integer] id The ID of a merge request.
92
+ # @param [Hash] options A customizable set of options.
93
+ # @option options [String] :merge_commit_message Custom merge commit message
94
+ # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
95
+ def accept_merge_request(project, id, options = {})
96
+ put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
97
+ end
98
+
99
+ # Gets the changes of a merge request.
100
+ #
101
+ # @example
102
+ # Gitlab.merge_request_changes(5, 1)
103
+ #
104
+ # @param [Integer, String] project The ID or name of a project.
105
+ # @param [Integer] id The ID of a merge request.
106
+ # @return [Gitlab::ObjectifiedHash] The merge request's changes.
107
+ def merge_request_changes(project, id)
108
+ get("/projects/#{url_encode project}/merge_requests/#{id}/changes")
109
+ end
110
+
111
+ # Gets the commits of a merge request.
112
+ #
113
+ # @example
114
+ # Gitlab.merge_request_commits(5, 1)
115
+ #
116
+ # @param [Integer, String] project The ID or name of a project.
117
+ # @param [Integer] id The ID of a merge request.
118
+ # @return [Array<Gitlab::ObjectifiedHash>] The merge request's commits.
119
+ def merge_request_commits(project, id)
120
+ get("/projects/#{url_encode project}/merge_requests/#{id}/commits")
121
+ end
97
122
 
98
- # Gets the changes of a merge request.
99
- #
100
- # @example
101
- # Gitlab.merge_request_changes(5, 1)
102
- #
103
- # @param [Integer, String] project The ID or name of a project.
104
- # @param [Integer] id The ID of a merge request.
105
- # @return [Gitlab::ObjectifiedHash] The merge request's changes.
106
- def merge_request_changes(project, id)
107
- get("/projects/#{url_encode project}/merge_requests/#{id}/changes")
108
- end
123
+ # List issues that will close on merge
124
+ #
125
+ # @example
126
+ # Gitlab.merge_request_closes_issues(5, 1)
127
+ #
128
+ # @param [Integer] project The ID of a project
129
+ # @param [Integer] iid The internal ID of a merge request
130
+ def merge_request_closes_issues(project_id, merge_request_iid)
131
+ get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
132
+ end
109
133
 
110
- # Gets the commits of a merge request.
111
- #
112
- # @example
113
- # Gitlab.merge_request_commits(5, 1)
114
- #
115
- # @param [Integer, String] project The ID or name of a project.
116
- # @param [Integer] id The ID of a merge request.
117
- # @return [Array<Gitlab::ObjectifiedHash>] The merge request's commits.
118
- def merge_request_commits(project, id)
119
- get("/projects/#{url_encode project}/merge_requests/#{id}/commits")
120
- end
134
+ # Subscribes to a merge request.
135
+ #
136
+ # @example
137
+ # Gitlab.subscribe_to_merge_request(5, 1)
138
+ # Gitlab.subscribe_to_merge_request('gitlab', 1)
139
+ #
140
+ # @param [Integer, String] project The ID or name of a project.
141
+ # @param [Integer] id The ID of a merge request.
142
+ # @return [Gitlab::ObjectifiedHash] Information about subscribed merge request.
143
+ def subscribe_to_merge_request(project, id)
144
+ post("/projects/#{url_encode project}/merge_requests/#{id}/subscribe")
145
+ end
121
146
 
122
- # List issues that will close on merge
123
- #
124
- # @example
125
- # Gitlab.merge_request_closes_issues(5, 1)
126
- #
127
- # @param [Integer] project The ID of a project
128
- # @param [Integer] iid The internal ID of a merge request
129
- def merge_request_closes_issues(project_id, merge_request_iid)
130
- get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
131
- end
147
+ # Unsubscribes from a merge request.
148
+ #
149
+ # @example
150
+ # Gitlab.unsubscribe_from_merge_request(5, 1)
151
+ # Gitlab.unsubscribe_from_merge_request('gitlab', 1)
152
+ #
153
+ # @param [Integer, String] project The ID or name of a project.
154
+ # @param [Integer] id The ID of a merge request.
155
+ # @return [Gitlab::ObjectifiedHash] Information about unsubscribed merge request.
156
+ def unsubscribe_from_merge_request(project, id)
157
+ post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe")
158
+ end
132
159
 
133
- # Subscribes to a merge request.
134
- #
135
- # @example
136
- # Gitlab.subscribe_to_merge_request(5, 1)
137
- # Gitlab.subscribe_to_merge_request('gitlab', 1)
138
- #
139
- # @param [Integer, String] project The ID or name of a project.
140
- # @param [Integer] id The ID of a merge request.
141
- # @return [Gitlab::ObjectifiedHash] Information about subscribed merge request.
142
- def subscribe_to_merge_request(project, id)
143
- post("/projects/#{url_encode project}/merge_requests/#{id}/subscribe")
144
- end
160
+ # List project merge request discussions
161
+ #
162
+ # @example
163
+ # Gitlab.merge_request_discussions(5, 1)
164
+ # Gitlab.merge_request_discussions('gitlab', 1)
165
+ # @param [Integer, String] project The ID or name of a project.
166
+ # @param [Integer] id The ID of a merge request.
167
+ # @return [Gitlab::ObjectifiedHash] List of the merge request discussions.
168
+ def merge_request_discussions(project, merge_request_id)
169
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions")
170
+ end
145
171
 
146
- # Unsubscribes from a merge request.
147
- #
148
- # @example
149
- # Gitlab.unsubscribe_from_merge_request(5, 1)
150
- # Gitlab.unsubscribe_from_merge_request('gitlab', 1)
151
- #
152
- # @param [Integer, String] project The ID or name of a project.
153
- # @param [Integer] id The ID of a merge request.
154
- # @return [Gitlab::ObjectifiedHash] Information about unsubscribed merge request.
155
- def unsubscribe_from_merge_request(project, id)
156
- post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe")
157
- end
172
+ # Get single merge request discussion
173
+ #
174
+ # @example
175
+ # Gitlab.merge_request_discussion(5, 1, 1)
176
+ # Gitlab.merge_request_discussion('gitlab', 1, 1)
177
+ # @param [Integer, String] project The ID or name of a project.
178
+ # @param [Integer] id The ID of a merge request.
179
+ # @param [Integer] discussion_id The ID of a discussion.
180
+ # @return [Gitlab::ObjectifiedHash] The merge request discussion.
181
+ def merge_request_discussion(project, merge_request_id, discussion_id)
182
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}")
183
+ end
158
184
 
159
- # List project merge request discussions
160
- #
161
- # @example
162
- # Gitlab.merge_request_discussions(5, 1)
163
- # Gitlab.merge_request_discussions('gitlab', 1)
164
- # @param [Integer, String] project The ID or name of a project.
165
- # @param [Integer] id The ID of a merge request.
166
- # @return [Gitlab::ObjectifiedHash] List of the merge request discussions.
167
- def merge_request_discussions(project, merge_request_id)
168
- get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions")
169
- end
185
+ # Create new merge request discussion
186
+ #
187
+ # @example
188
+ # Gitlab.create_merge_request_discussion(5, 1, body: 'discuss')
189
+ # Gitlab.create_merge_request_discussion('gitlab', 1, body: 'discuss')
190
+ # @param [Integer, String] project The ID or name of a project.
191
+ # @param [Integer] id The ID of a merge request.
192
+ # @param [Hash] options A customizable set of options.
193
+ # * :body (String) The content of a discussion
194
+ # * :created_at (String) Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z
195
+ # * :position (Hash) Position when creating a diff note
196
+ # * :base_sha (String) Base commit SHA in the source branch
197
+ # * :start_sha (String) SHA referencing commit in target branch
198
+ # * :head_sha (String) SHA referencing HEAD of this merge request
199
+ # * :position_type (String) Type of the position reference', allowed values: 'text' or 'image'
200
+ # * :new_path (String) File path after change
201
+ # * :new_line (Integer) Line number after change (for 'text' diff notes)
202
+ # * :old_path (String) File path before change
203
+ # * :old_line (Integer) Line number before change (for 'text' diff notes)
204
+ # * :width (Integer) Width of the image (for 'image' diff notes)
205
+ # * :height (Integer) Height of the image (for 'image' diff notes)
206
+ # * :x (Integer) X coordinate (for 'image' diff notes)
207
+ # * :y (Integer) Y coordinate (for 'image' diff notes)
208
+ # @return [Gitlab::ObjectifiedHash] The created merge request discussion.
209
+ def create_merge_request_discussion(project, merge_request_id, options = {})
210
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", body: options)
211
+ end
170
212
 
171
- # Get single merge request discussion
172
- #
173
- # @example
174
- # Gitlab.merge_request_discussion(5, 1, 1)
175
- # Gitlab.merge_request_discussion('gitlab', 1, 1)
176
- # @param [Integer, String] project The ID or name of a project.
177
- # @param [Integer] id The ID of a merge request.
178
- # @param [Integer] discussion_id The ID of a discussion.
179
- # @return [Gitlab::ObjectifiedHash] The merge request discussion.
180
- def merge_request_discussion(project, merge_request_id, discussion_id)
181
- get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}")
182
- end
213
+ # Resolve a merge request discussion
214
+ #
215
+ # @example
216
+ # Gitlab.resolve_merge_request_discussion(5, 1, 1, true)
217
+ # Gitlab.resolve_merge_request_discussion('gitlab', 1, 1, false)
218
+ # @param [Integer, String] project The ID or name of a project.
219
+ # @param [Integer] id The ID of a merge request.
220
+ # @param [Integer] discussion_id The ID of a discussion.
221
+ # @param [Hash] options A customizable set of options.
222
+ # @option options [Boolean] :resolved Resolve/unresolve the discussion.
223
+ # @return [Gitlab::ObjectifiedHash] The merge request discussion.
224
+ def resolve_merge_request_discussion(project, merge_request_id, discussion_id, options)
225
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}", body: options)
226
+ end
183
227
 
184
- # Create new merge request discussion
185
- #
186
- # @example
187
- # Gitlab.create_merge_request_discussion(5, 1, body: 'discuss')
188
- # Gitlab.create_merge_request_discussion('gitlab', 1, body: 'discuss')
189
- # @param [Integer, String] project The ID or name of a project.
190
- # @param [Integer] id The ID of a merge request.
191
- # @param [Hash] options A customizable set of options.
192
- # * :body (String) The content of a discussion
193
- # * :created_at (String) Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z
194
- # * :position (Hash) Position when creating a diff note
195
- # * :base_sha (String) Base commit SHA in the source branch
196
- # * :start_sha (String) SHA referencing commit in target branch
197
- # * :head_sha (String) SHA referencing HEAD of this merge request
198
- # * :position_type (String) Type of the position reference', allowed values: 'text' or 'image'
199
- # * :new_path (String) File path after change
200
- # * :new_line (Integer) Line number after change (for 'text' diff notes)
201
- # * :old_path (String) File path before change
202
- # * :old_line (Integer) Line number before change (for 'text' diff notes)
203
- # * :width (Integer) Width of the image (for 'image' diff notes)
204
- # * :height (Integer) Height of the image (for 'image' diff notes)
205
- # * :x (Integer) X coordinate (for 'image' diff notes)
206
- # * :y (Integer) Y coordinate (for 'image' diff notes)
207
- # @return [Gitlab::ObjectifiedHash] The created merge request discussion.
208
- def create_merge_request_discussion(project, merge_request_id, options={})
209
- post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", body: options)
210
- end
228
+ # Add note to existing merge request discussion
229
+ #
230
+ # @example
231
+ # Gitlab.create_merge_request_discussion_note(5, 1, 1, note_id: 1, body: 'note')
232
+ # Gitlab.create_merge_request_discussion_note('gitlab', 1, 1, note_id: 1, body: 'note')
233
+ # @param [Integer, String] project The ID or name of a project.
234
+ # @param [Integer] id The ID of a merge request.
235
+ # @param [Integer] discussion_id The ID of a discussion.
236
+ # @param [Hash] options A customizable set of options.
237
+ # @option options [Integer] :note_id The ID of a discussion note.
238
+ # @option options [String] :body The content of a discussion.
239
+ # @option options [String] :created_at Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z.
240
+ # @return [Gitlab::ObjectifiedHash] The merge request discussion note.
241
+ def create_merge_request_discussion_note(project, merge_request_id, discussion_id, options)
242
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes", body: options)
243
+ end
211
244
 
212
- # Resolve a merge request discussion
213
- #
214
- # @example
215
- # Gitlab.resolve_merge_request_discussion(5, 1, 1, true)
216
- # Gitlab.resolve_merge_request_discussion('gitlab', 1, 1, false)
217
- # @param [Integer, String] project The ID or name of a project.
218
- # @param [Integer] id The ID of a merge request.
219
- # @param [Integer] discussion_id The ID of a discussion.
220
- # @param [Hash] options A customizable set of options.
221
- # @option options [Boolean] :resolved Resolve/unresolve the discussion.
222
- # @return [Gitlab::ObjectifiedHash] The merge request discussion.
223
- def resolve_merge_request_discussion(project, merge_request_id, discussion_id, options)
224
- put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}", body: options)
225
- end
245
+ # Modify an existing merge request discussion note
246
+ #
247
+ # @example
248
+ # Gitlab.update_merge_request_discussion_note(5, 1, 1, 1, body: 'note')
249
+ # Gitlab.update_merge_request_discussion_note('gitlab', 1, 1, 1, body: 'note')
250
+ # @param [Integer, String] project The ID or name of a project.
251
+ # @param [Integer] id The ID of a merge request.
252
+ # @param [Integer] discussion_id The ID of a discussion.
253
+ # @param [Integer] note_id The ID of a discussion note.
254
+ # @param [Hash] options A customizable set of options.
255
+ # @option options [String] :body The content of a discussion.
256
+ # @option options [Boolean] :resolved Resolve/unresolve the note.
257
+ # @return [Gitlab::ObjectifiedHash] The merge request discussion note.
258
+ def update_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id, options)
259
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}", body: options)
260
+ end
226
261
 
227
- # Add note to existing merge request discussion
228
- #
229
- # @example
230
- # Gitlab.create_merge_request_discussion_note(5, 1, 1, note_id: 1, body: 'note')
231
- # Gitlab.create_merge_request_discussion_note('gitlab', 1, 1, note_id: 1, body: 'note')
232
- # @param [Integer, String] project The ID or name of a project.
233
- # @param [Integer] id The ID of a merge request.
234
- # @param [Integer] discussion_id The ID of a discussion.
235
- # @param [Hash] options A customizable set of options.
236
- # @option options [Integer] :note_id The ID of a discussion note.
237
- # @option options [String] :body The content of a discussion.
238
- # @option options [String] :created_at Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z.
239
- # @return [Gitlab::ObjectifiedHash] The merge request discussion note.
240
- def create_merge_request_discussion_note(project, merge_request_id, discussion_id, options)
241
- post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes", body: options)
242
- end
262
+ # Delete a merge request discussion note
263
+ #
264
+ # @example
265
+ # Gitlab.delete_merge_request_discussion_note(5, 1, 1, 1)
266
+ # Gitlab.delete_merge_request_discussion_note('gitlab', 1, 1, 1)
267
+ # @param [Integer, String] project The ID or name of a project.
268
+ # @param [Integer] id The ID of a merge request.
269
+ # @param [Integer] discussion_id The ID of a discussion.
270
+ # @param [Integer] note_id The ID of a discussion note.
271
+ # @return [Gitlab::ObjectifiedHash] An empty response.
272
+ def delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id)
273
+ delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
274
+ end
243
275
 
244
- # Modify an existing merge request discussion note
245
- #
246
- # @example
247
- # Gitlab.update_merge_request_discussion_note(5, 1, 1, 1, body: 'note')
248
- # Gitlab.update_merge_request_discussion_note('gitlab', 1, 1, 1, body: 'note')
249
- # @param [Integer, String] project The ID or name of a project.
250
- # @param [Integer] id The ID of a merge request.
251
- # @param [Integer] discussion_id The ID of a discussion.
252
- # @param [Integer] note_id The ID of a discussion note.
253
- # @param [Hash] options A customizable set of options.
254
- # @option options [String] :body The content of a discussion.
255
- # @option options [Boolean] :resolved Resolve/unresolve the note.
256
- # @return [Gitlab::ObjectifiedHash] The merge request discussion note.
257
- def update_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id, options)
258
- put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}", body: options)
259
- end
276
+ # Gets a list of merge request diff versions
277
+ #
278
+ # @example
279
+ # Gitlab.merge_request_versions(5, 1)
280
+ # Gitlab.merge_request_versions('gitlab', 1)
281
+ # @param [Integer, String] project The ID or name of a project.
282
+ # @param [Integer] id The ID of a merge request.
283
+ # @return [Gitlab::ObjectifiedHash] A list of the merge request versions.
284
+ def merge_request_diff_versions(project, merge_request_id)
285
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions")
286
+ end
260
287
 
261
- # Delete a merge request discussion note
262
- #
263
- # @example
264
- # Gitlab.delete_merge_request_discussion_note(5, 1, 1, 1)
265
- # Gitlab.delete_merge_request_discussion_note('gitlab', 1, 1, 1)
266
- # @param [Integer, String] project The ID or name of a project.
267
- # @param [Integer] id The ID of a merge request.
268
- # @param [Integer] discussion_id The ID of a discussion.
269
- # @param [Integer] note_id The ID of a discussion note.
270
- # @return [Gitlab::ObjectifiedHash] An empty response.
271
- def delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id)
272
- delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
273
- end
288
+ # Gets the diff a single merge request diff version\
289
+ #
290
+ # @example
291
+ # Gitlab.merge_request_diff_version(5, 1, 1)
292
+ # Gitlab.merge_request_diff_version('gitlab', 1, 1)
293
+ # @param [Integer, String] project The ID or name of a project.
294
+ # @param [Integer] id The ID of a merge request.
295
+ # @param [Integer] id The ID of a merge request diff version.
296
+ # @return [Gitlab::ObjectifiedHash] Record of the specific diff
297
+ def merge_request_diff_version(project, merge_request_id, version_id)
298
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions/#{version_id}")
274
299
  end
275
300
  end