gitlab 3.7.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +24 -0
- data/README.md +7 -6
- data/gitlab.gemspec +4 -6
- data/lib/gitlab/client.rb +24 -0
- data/lib/gitlab/client/branches.rb +13 -13
- data/lib/gitlab/client/build_triggers.rb +9 -9
- data/lib/gitlab/client/build_variables.rb +11 -11
- data/lib/gitlab/client/builds.rb +16 -16
- data/lib/gitlab/client/commits.rb +39 -14
- data/lib/gitlab/client/groups.rb +1 -1
- data/lib/gitlab/client/issues.rb +40 -16
- data/lib/gitlab/client/labels.rb +9 -9
- data/lib/gitlab/client/merge_requests.rb +61 -24
- data/lib/gitlab/client/milestones.rb +25 -11
- data/lib/gitlab/client/namespaces.rb +2 -1
- data/lib/gitlab/client/notes.rb +16 -16
- data/lib/gitlab/client/pipelines.rb +68 -0
- data/lib/gitlab/client/projects.rb +111 -49
- data/lib/gitlab/client/repositories.rb +27 -23
- data/lib/gitlab/client/repository_files.rb +29 -10
- data/lib/gitlab/client/runners.rb +15 -15
- data/lib/gitlab/client/services.rb +8 -6
- data/lib/gitlab/client/snippets.rb +13 -13
- data/lib/gitlab/client/system_hooks.rb +1 -1
- data/lib/gitlab/client/tags.rb +13 -13
- data/lib/gitlab/client/users.rb +12 -5
- data/lib/gitlab/file_response.rb +1 -0
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/merge_request_closes_issues.json +1 -0
- data/spec/fixtures/milestone_merge_requests.json +1 -0
- data/spec/fixtures/pipeline.json +23 -0
- data/spec/fixtures/pipeline_cancel.json +23 -0
- data/spec/fixtures/pipeline_create.json +23 -0
- data/spec/fixtures/pipeline_retry.json +23 -0
- data/spec/fixtures/pipelines.json +48 -0
- data/spec/fixtures/project_commit_create.json +22 -0
- data/spec/fixtures/project_star.json +44 -0
- data/spec/fixtures/project_unstar.json +44 -0
- data/spec/fixtures/{git_hook.json → push_rule.json} +0 -0
- data/spec/gitlab/cli_spec.rb +9 -0
- data/spec/gitlab/client/client_spec.rb +11 -0
- data/spec/gitlab/client/commits_spec.rb +31 -0
- data/spec/gitlab/client/issues_spec.rb +48 -0
- data/spec/gitlab/client/merge_requests_spec.rb +57 -10
- data/spec/gitlab/client/milestones_spec.rb +16 -0
- data/spec/gitlab/client/pipelines_spec.rb +95 -0
- data/spec/gitlab/client/projects_spec.rb +116 -38
- data/spec/gitlab/client/repositories_spec.rb +0 -15
- data/spec/gitlab/client/repository_files_spec.rb +17 -2
- data/spec/gitlab/client/users_spec.rb +31 -13
- data/spec/gitlab/file_response_spec.rb +6 -1
- metadata +53 -43
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to repository commits.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/commits.html
|
4
4
|
module Commits
|
5
5
|
# Gets a list of project commits.
|
6
6
|
#
|
@@ -8,14 +8,14 @@ class Gitlab::Client
|
|
8
8
|
# Gitlab.commits('viking')
|
9
9
|
# Gitlab.repo_commits('gitlab', { ref_name: 'api' })
|
10
10
|
#
|
11
|
-
# @param [Integer] project The ID of a project.
|
11
|
+
# @param [Integer, String] project The ID or name of a project.
|
12
12
|
# @param [Hash] options A customizable set of options.
|
13
13
|
# @option options [String] :ref_name The branch or tag name of a project repository.
|
14
14
|
# @option options [Integer] :page The page number.
|
15
15
|
# @option options [Integer] :per_page The number of results per page.
|
16
16
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
17
17
|
def commits(project, options={})
|
18
|
-
get("/projects/#{project}/repository/commits", query: options)
|
18
|
+
get("/projects/#{url_encode project}/repository/commits", query: options)
|
19
19
|
end
|
20
20
|
alias_method :repo_commits, :commits
|
21
21
|
|
@@ -25,11 +25,11 @@ class Gitlab::Client
|
|
25
25
|
# Gitlab.commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
26
26
|
# Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
27
27
|
#
|
28
|
-
# @param [Integer] project The ID of a project.
|
28
|
+
# @param [Integer, String] project The ID or name of a project.
|
29
29
|
# @param [String] sha The commit hash or name of a repository branch or tag
|
30
30
|
# @return [Gitlab::ObjectifiedHash]
|
31
31
|
def commit(project, sha)
|
32
|
-
get("/projects/#{project}/repository/commits/#{sha}")
|
32
|
+
get("/projects/#{url_encode project}/repository/commits/#{sha}")
|
33
33
|
end
|
34
34
|
alias_method :repo_commit, :commit
|
35
35
|
|
@@ -39,11 +39,11 @@ class Gitlab::Client
|
|
39
39
|
# Gitlab.commit_diff(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
|
40
40
|
# Gitlab.repo_commit_diff(3, 'ed899a2f4b50b4370feeea94676502b42383c746')
|
41
41
|
#
|
42
|
-
# @param [Integer] project The ID of a project.
|
42
|
+
# @param [Integer, String] project The ID or name of a project.
|
43
43
|
# @param [String] sha The name of a repository branch or tag or if not given the default branch.
|
44
44
|
# @return [Gitlab::ObjectifiedHash]
|
45
45
|
def commit_diff(project, sha)
|
46
|
-
get("/projects/#{project}/repository/commits/#{sha}/diff")
|
46
|
+
get("/projects/#{url_encode project}/repository/commits/#{sha}/diff")
|
47
47
|
end
|
48
48
|
alias_method :repo_commit_diff, :commit_diff
|
49
49
|
|
@@ -58,7 +58,7 @@ class Gitlab::Client
|
|
58
58
|
# @option options [Integer] :per_page The number of results per page.
|
59
59
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
60
60
|
def commit_comments(project, commit, options={})
|
61
|
-
get("/projects/#{project}/repository/commits/#{commit}/comments", query: options)
|
61
|
+
get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options)
|
62
62
|
end
|
63
63
|
alias_method :repo_commit_comments, :commit_comments
|
64
64
|
|
@@ -67,7 +67,7 @@ class Gitlab::Client
|
|
67
67
|
# @example
|
68
68
|
# Gitlab.create_commit_comment(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b', 'Nice work on this commit!')
|
69
69
|
#
|
70
|
-
# @param [Integer] project The ID of a project.
|
70
|
+
# @param [Integer, String] project The ID or name of a project.
|
71
71
|
# @param [String] sha The commit hash or name of a repository branch or tag.
|
72
72
|
# @param [String] note The text of a comment.
|
73
73
|
# @param [Hash] options A customizable set of options.
|
@@ -76,7 +76,7 @@ class Gitlab::Client
|
|
76
76
|
# @option options [String] :line_type The line type (new or old).
|
77
77
|
# @return [Gitlab::ObjectifiedHash] Information about created comment.
|
78
78
|
def create_commit_comment(project, commit, note, options={})
|
79
|
-
post("/projects/#{project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
|
79
|
+
post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
|
80
80
|
end
|
81
81
|
alias_method :repo_create_commit_comment, :create_commit_comment
|
82
82
|
|
@@ -87,12 +87,12 @@ class Gitlab::Client
|
|
87
87
|
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins' })
|
88
88
|
# Gitlab.commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', { name: 'jenkins', all: true })
|
89
89
|
#
|
90
|
-
# @param [Integer] project The ID of a project.
|
90
|
+
# @param [Integer, String] project The ID or name of a project.
|
91
91
|
# @param [String] sha The commit hash
|
92
92
|
# @param [Hash] options A customizable set of options.
|
93
93
|
# @option options [String] :ref Filter by ref name, it can be branch or tag
|
94
94
|
# @option options [String] :stage Filter by stage
|
95
|
-
# @option options [String] :name
|
95
|
+
# @option options [String] :name Filter by status name, eg. jenkins
|
96
96
|
# @option options [Boolean] :all The flag to return all statuses, not only latest ones
|
97
97
|
def commit_status(id, sha, options={})
|
98
98
|
get("/projects/#{id}/repository/commits/#{sha}/statuses", query: options)
|
@@ -106,16 +106,41 @@ class Gitlab::Client
|
|
106
106
|
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'failed', { name: 'jenkins' })
|
107
107
|
# Gitlab.update_commit_status(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'canceled', { name: 'jenkins', target_url: 'http://example.com/builds/1' })
|
108
108
|
#
|
109
|
-
# @param [Integer] project The ID of a project.
|
109
|
+
# @param [Integer, String] project The ID or name of a project.
|
110
110
|
# @param [String] sha The commit hash
|
111
111
|
# @param [String] state of the status. Can be: pending, running, success, failed, canceled
|
112
112
|
# @param [Hash] options A customizable set of options.
|
113
113
|
# @option options [String] :ref The ref (branch or tag) to which the status refers
|
114
|
-
# @option options [String] :name
|
114
|
+
# @option options [String] :name Filter by status name, eg. jenkins
|
115
115
|
# @option options [String] :target_url The target URL to associate with this status
|
116
116
|
def update_commit_status(id, sha, state, options={})
|
117
117
|
post("/projects/#{id}/statuses/#{sha}", query: options.merge(state: state))
|
118
118
|
end
|
119
119
|
alias_method :repo_update_commit_status, :update_commit_status
|
120
|
+
|
121
|
+
# Creates a single commit with one or more changes
|
122
|
+
#
|
123
|
+
# @see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
|
124
|
+
# Introduced in Gitlab 8.13
|
125
|
+
#
|
126
|
+
# @example
|
127
|
+
# Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'create', file_path: '/foo.txt', content: 'bar'}])
|
128
|
+
# Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'delete', file_path: '/foo.txt'}])
|
129
|
+
#
|
130
|
+
# @param [Integer, String] project The ID or name of a project.
|
131
|
+
# @param [String] branch the branch name you wish to commit to
|
132
|
+
# @param [String] message the commit message
|
133
|
+
# @param [Array[Hash]] An array of action hashes to commit as a batch. See the next table for what attributes it can take.
|
134
|
+
# @option options [String] :author_email the email address of the author
|
135
|
+
# @option options [String] :author_name the name of the author
|
136
|
+
# @return [Gitlab::ObjectifiedHash] hash of commit related data
|
137
|
+
def create_commit(project, branch, message, actions, options={})
|
138
|
+
payload = {
|
139
|
+
branch_name: branch,
|
140
|
+
commit_message: message,
|
141
|
+
actions: actions,
|
142
|
+
}.merge(options)
|
143
|
+
post("/projects/#{url_encode project}/repository/commits", query: payload)
|
144
|
+
end
|
120
145
|
end
|
121
146
|
end
|
data/lib/gitlab/client/groups.rb
CHANGED
data/lib/gitlab/client/issues.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to issues.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/issues.html
|
4
4
|
module Issues
|
5
5
|
# Gets a list of user's issues.
|
6
6
|
# Will return a list of project's issues if project ID passed.
|
@@ -10,16 +10,16 @@ class Gitlab::Client
|
|
10
10
|
# Gitlab.issues(5)
|
11
11
|
# Gitlab.issues({ per_page: 40 })
|
12
12
|
#
|
13
|
-
# @param [Integer] project The ID of a project.
|
13
|
+
# @param [Integer, String] project The ID or name of a project.
|
14
14
|
# @param [Hash] options A customizable set of options.
|
15
15
|
# @option options [Integer] :page The page number.
|
16
16
|
# @option options [Integer] :per_page The number of results per page.
|
17
17
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
18
18
|
def issues(project=nil, options={})
|
19
|
-
if project.to_i.zero?
|
19
|
+
if project.to_s.empty? && project.to_i.zero?
|
20
20
|
get("/issues", query: options)
|
21
21
|
else
|
22
|
-
get("/projects/#{project}/issues", query: options)
|
22
|
+
get("/projects/#{url_encode project}/issues", query: options)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -28,11 +28,11 @@ class Gitlab::Client
|
|
28
28
|
# @example
|
29
29
|
# Gitlab.issue(5, 42)
|
30
30
|
#
|
31
|
-
# @param [Integer] project The ID of a project.
|
31
|
+
# @param [Integer, String] project The ID or name of a project.
|
32
32
|
# @param [Integer] id The ID of an issue.
|
33
33
|
# @return [Gitlab::ObjectifiedHash]
|
34
34
|
def issue(project, id)
|
35
|
-
get("/projects/#{project}/issues/#{id}")
|
35
|
+
get("/projects/#{url_encode project}/issues/#{id}")
|
36
36
|
end
|
37
37
|
|
38
38
|
# Creates a new issue.
|
@@ -41,7 +41,7 @@ class Gitlab::Client
|
|
41
41
|
# Gitlab.create_issue(5, 'New issue')
|
42
42
|
# Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })
|
43
43
|
#
|
44
|
-
# @param [Integer] project The ID of a project.
|
44
|
+
# @param [Integer, String] project The ID or name of a project.
|
45
45
|
# @param [String] title The title of an issue.
|
46
46
|
# @param [Hash] options A customizable set of options.
|
47
47
|
# @option options [String] :description The description of an issue.
|
@@ -51,7 +51,7 @@ class Gitlab::Client
|
|
51
51
|
# @return [Gitlab::ObjectifiedHash] Information about created issue.
|
52
52
|
def create_issue(project, title, options={})
|
53
53
|
body = { title: title }.merge(options)
|
54
|
-
post("/projects/#{project}/issues", body: body)
|
54
|
+
post("/projects/#{url_encode project}/issues", body: body)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Updates an issue.
|
@@ -59,7 +59,7 @@ class Gitlab::Client
|
|
59
59
|
# @example
|
60
60
|
# Gitlab.edit_issue(6, 1, { title: 'Updated title' })
|
61
61
|
#
|
62
|
-
# @param [Integer] project The ID of a project.
|
62
|
+
# @param [Integer, String] project The ID or name of a project.
|
63
63
|
# @param [Integer] id The ID of an issue.
|
64
64
|
# @param [Hash] options A customizable set of options.
|
65
65
|
# @option options [String] :title The title of an issue.
|
@@ -70,7 +70,7 @@ class Gitlab::Client
|
|
70
70
|
# @option options [String] :state_event The state event of an issue ('close' or 'reopen').
|
71
71
|
# @return [Gitlab::ObjectifiedHash] Information about updated issue.
|
72
72
|
def edit_issue(project, id, options={})
|
73
|
-
put("/projects/#{project}/issues/#{id}", body: options)
|
73
|
+
put("/projects/#{url_encode project}/issues/#{id}", body: options)
|
74
74
|
end
|
75
75
|
|
76
76
|
# Closes an issue.
|
@@ -78,11 +78,11 @@ class Gitlab::Client
|
|
78
78
|
# @example
|
79
79
|
# Gitlab.close_issue(3, 42)
|
80
80
|
#
|
81
|
-
# @param [Integer] project The ID of a project.
|
81
|
+
# @param [Integer, String] project The ID or name of a project.
|
82
82
|
# @param [Integer] id The ID of an issue.
|
83
83
|
# @return [Gitlab::ObjectifiedHash] Information about closed issue.
|
84
84
|
def close_issue(project, id)
|
85
|
-
put("/projects/#{project}/issues/#{id}", body: { state_event: 'close' })
|
85
|
+
put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'close' })
|
86
86
|
end
|
87
87
|
|
88
88
|
# Reopens an issue.
|
@@ -90,11 +90,35 @@ class Gitlab::Client
|
|
90
90
|
# @example
|
91
91
|
# Gitlab.reopen_issue(3, 42)
|
92
92
|
#
|
93
|
-
# @param [Integer] project The ID of a project.
|
93
|
+
# @param [Integer, String] project The ID or name of a project.
|
94
94
|
# @param [Integer] id The ID of an issue.
|
95
95
|
# @return [Gitlab::ObjectifiedHash] Information about reopened issue.
|
96
96
|
def reopen_issue(project, id)
|
97
|
-
put("/projects/#{project}/issues/#{id}", body: { state_event: 'reopen' })
|
97
|
+
put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'reopen' })
|
98
|
+
end
|
99
|
+
|
100
|
+
# Subscribe to an issue.
|
101
|
+
#
|
102
|
+
# @example
|
103
|
+
# Gitlab.subscribe_to_issue(3, 42)
|
104
|
+
#
|
105
|
+
# @param [Integer, String] project The ID or name of a project.
|
106
|
+
# @param [Integer] id The ID of an issue.
|
107
|
+
# @return [Gitlab::ObjectifiedHash] Information about subscribed issue.
|
108
|
+
def subscribe_to_issue(project, id)
|
109
|
+
post("/projects/#{url_encode project}/issues/#{id}/subscribe")
|
110
|
+
end
|
111
|
+
|
112
|
+
# Unsubscribe from an issue.
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
# Gitlab.unsubscribe_from_issue(3, 42)
|
116
|
+
#
|
117
|
+
# @param [Integer, String] project The ID or name of a project.
|
118
|
+
# @param [Integer] id The ID of an issue.
|
119
|
+
# @return [Gitlab::ObjectifiedHash] Information about unsubscribed issue.
|
120
|
+
def unsubscribe_from_issue(project, id)
|
121
|
+
post("/projects/#{url_encode project}/issues/#{id}/unsubscribe")
|
98
122
|
end
|
99
123
|
|
100
124
|
# Deletes an issue.
|
@@ -103,11 +127,11 @@ class Gitlab::Client
|
|
103
127
|
# @example
|
104
128
|
# Gitlab.delete_issue(3, 42)
|
105
129
|
#
|
106
|
-
# @param [Integer] project The ID of a project.
|
130
|
+
# @param [Integer, String] project The ID or name of a project.
|
107
131
|
# @param [Integer] id The ID of an issue.
|
108
132
|
# @return [Gitlab::ObjectifiedHash] Information about deleted issue.
|
109
133
|
def delete_issue(project, id)
|
110
|
-
delete("/projects/#{project}/issues/#{id}")
|
134
|
+
delete("/projects/#{url_encode project}/issues/#{id}")
|
111
135
|
end
|
112
136
|
end
|
113
137
|
end
|
data/lib/gitlab/client/labels.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to labels.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/labels.html
|
4
4
|
module Labels
|
5
5
|
# Gets a list of project's labels.
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
# Gitlab.labels(5)
|
9
9
|
#
|
10
|
-
# @param [Integer] project The ID of a project.
|
10
|
+
# @param [Integer, String] project The ID or name of a project.
|
11
11
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
12
12
|
def labels(project)
|
13
|
-
get("/projects/#{project}/labels")
|
13
|
+
get("/projects/#{url_encode project}/labels")
|
14
14
|
end
|
15
15
|
|
16
16
|
# Creates a new label.
|
@@ -18,12 +18,12 @@ class Gitlab::Client
|
|
18
18
|
# @example
|
19
19
|
# Gitlab.create_label(42, "Backlog", '#DD10AA')
|
20
20
|
#
|
21
|
-
# @param [Integer] project The ID of a project.
|
21
|
+
# @param [Integer, String] project The ID or name of a project.
|
22
22
|
# @option [String] name The name of a label.
|
23
23
|
# @option [String] color The color of a label.
|
24
24
|
# @return [Gitlab::ObjectifiedHash] Information about created label.
|
25
25
|
def create_label(project, name, color)
|
26
|
-
post("/projects/#{project}/labels", body: { name: name, color: color })
|
26
|
+
post("/projects/#{url_encode project}/labels", body: { name: name, color: color })
|
27
27
|
end
|
28
28
|
|
29
29
|
# Updates a label.
|
@@ -32,14 +32,14 @@ class Gitlab::Client
|
|
32
32
|
# Gitlab.edit_label(42, "Backlog", { new_name: 'TODO' })
|
33
33
|
# Gitlab.edit_label(42, "Backlog", { new_name: 'TODO', color: '#DD10AA' })
|
34
34
|
#
|
35
|
-
# @param [Integer] project The ID of a project.
|
35
|
+
# @param [Integer, String] project The ID or name of a project.
|
36
36
|
# @param [String] name The name of a label.
|
37
37
|
# @param [Hash] options A customizable set of options.
|
38
38
|
# @option options [String] :new_name The new name of a label.
|
39
39
|
# @option options [String] :color The color of a label.
|
40
40
|
# @return [Gitlab::ObjectifiedHash] Information about updated label.
|
41
41
|
def edit_label(project, name, options={})
|
42
|
-
put("/projects/#{project}/labels", body: options.merge(name: name))
|
42
|
+
put("/projects/#{url_encode project}/labels", body: options.merge(name: name))
|
43
43
|
end
|
44
44
|
|
45
45
|
# Deletes a label.
|
@@ -47,11 +47,11 @@ class Gitlab::Client
|
|
47
47
|
# @example
|
48
48
|
# Gitlab.delete_label(2, 'Backlog')
|
49
49
|
#
|
50
|
-
# @param [Integer] project The ID of a project.
|
50
|
+
# @param [Integer, String] project The ID or name of a project.
|
51
51
|
# @param [String] name The name of a label.
|
52
52
|
# @return [Gitlab::ObjectifiedHash] Information about deleted label.
|
53
53
|
def delete_label(project, name)
|
54
|
-
delete("/projects/#{project}/labels", body: { name: name })
|
54
|
+
delete("/projects/#{url_encode project}/labels", body: { name: name })
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gitlab::Client
|
2
2
|
# Defines methods related to merge requests.
|
3
|
-
# @see https://
|
3
|
+
# @see https://docs.gitlab.com/ce/api/merge_requests.html
|
4
4
|
module MergeRequests
|
5
5
|
# Gets a list of project merge requests.
|
6
6
|
#
|
@@ -8,13 +8,13 @@ class Gitlab::Client
|
|
8
8
|
# Gitlab.merge_requests(5)
|
9
9
|
# Gitlab.merge_requests({ per_page: 40 })
|
10
10
|
#
|
11
|
-
# @param [Integer] project The ID of a project.
|
11
|
+
# @param [Integer, String] project The ID or name of a project.
|
12
12
|
# @param [Hash] options A customizable set of options.
|
13
13
|
# @option options [Integer] :page The page number.
|
14
14
|
# @option options [Integer] :per_page The number of results per page.
|
15
15
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
16
16
|
def merge_requests(project, options={})
|
17
|
-
get("/projects/#{project}/merge_requests", query: options)
|
17
|
+
get("/projects/#{url_encode project}/merge_requests", query: options)
|
18
18
|
end
|
19
19
|
|
20
20
|
# Gets a single merge request.
|
@@ -22,11 +22,11 @@ class Gitlab::Client
|
|
22
22
|
# @example
|
23
23
|
# Gitlab.merge_request(5, 36)
|
24
24
|
#
|
25
|
-
# @param [Integer] project The ID of a project.
|
25
|
+
# @param [Integer, String] project The ID or name of a project.
|
26
26
|
# @param [Integer] id The ID of a merge request.
|
27
27
|
# @return <Gitlab::ObjectifiedHash]
|
28
28
|
def merge_request(project, id)
|
29
|
-
get("/projects/#{project}/
|
29
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}")
|
30
30
|
end
|
31
31
|
|
32
32
|
# Creates a merge request.
|
@@ -37,7 +37,7 @@ class Gitlab::Client
|
|
37
37
|
# Gitlab.create_merge_request(5, 'New merge request',
|
38
38
|
# { source_branch: 'source_branch', target_branch: 'target_branch', assignee_id: 42 })
|
39
39
|
#
|
40
|
-
# @param [Integer] project The ID of a project.
|
40
|
+
# @param [Integer, String] project The ID or name of a project.
|
41
41
|
# @param [String] title The title of a merge request.
|
42
42
|
# @param [Hash] options A customizable set of options.
|
43
43
|
# @option options [String] :source_branch (required) The source branch name.
|
@@ -47,7 +47,7 @@ class Gitlab::Client
|
|
47
47
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
|
48
48
|
def create_merge_request(project, title, options={})
|
49
49
|
body = { title: title }.merge(options)
|
50
|
-
post("/projects/#{project}/merge_requests", body: body)
|
50
|
+
post("/projects/#{url_encode project}/merge_requests", body: body)
|
51
51
|
end
|
52
52
|
|
53
53
|
# Updates a merge request.
|
@@ -55,7 +55,7 @@ class Gitlab::Client
|
|
55
55
|
# @example
|
56
56
|
# Gitlab.update_merge_request(5, 42, { title: 'New title' })
|
57
57
|
#
|
58
|
-
# @param [Integer] project The ID of a project.
|
58
|
+
# @param [Integer, String] project The ID or name of a project.
|
59
59
|
# @param [Integer] id The ID of a merge request.
|
60
60
|
# @param [Hash] options A customizable set of options.
|
61
61
|
# @option options [String] :title The title of a merge request.
|
@@ -65,7 +65,7 @@ class Gitlab::Client
|
|
65
65
|
# @option options [String] :state_event New state (close|reopen|merge).
|
66
66
|
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
|
67
67
|
def update_merge_request(project, id, options={})
|
68
|
-
put("/projects/#{project}/
|
68
|
+
put("/projects/#{url_encode project}/merge_requests/#{id}", body: options)
|
69
69
|
end
|
70
70
|
|
71
71
|
# Accepts a merge request.
|
@@ -73,13 +73,13 @@ class Gitlab::Client
|
|
73
73
|
# @example
|
74
74
|
# Gitlab.accept_merge_request(5, 42, { merge_commit_message: 'Nice!' })
|
75
75
|
#
|
76
|
-
# @param [Integer] project The ID of a project.
|
76
|
+
# @param [Integer, String] project The ID or name of a project.
|
77
77
|
# @param [Integer] id The ID of a merge request.
|
78
78
|
# @param [Hash] options A customizable set of options.
|
79
79
|
# @option options [String] :merge_commit_message Custom merge commit message
|
80
80
|
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
|
81
81
|
def accept_merge_request(project, id, options={})
|
82
|
-
put("/projects/#{project}/
|
82
|
+
put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
|
83
83
|
end
|
84
84
|
|
85
85
|
# Adds a comment to a merge request.
|
@@ -88,12 +88,12 @@ class Gitlab::Client
|
|
88
88
|
# Gitlab.create_merge_request_comment(5, 1, "Awesome merge!")
|
89
89
|
# Gitlab.create_merge_request_comment('gitlab', 1, "Awesome merge!")
|
90
90
|
#
|
91
|
-
# @param [Integer] project The ID of a project.
|
91
|
+
# @param [Integer, String] project The ID or name of a project.
|
92
92
|
# @param [Integer] id The ID of a merge request.
|
93
93
|
# @param [String] note The content of a comment.
|
94
94
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
|
95
95
|
def create_merge_request_comment(project, id, note)
|
96
|
-
post("/projects/#{project}/merge_requests/#{id}/notes", body: { body: note })
|
96
|
+
post("/projects/#{url_encode project}/merge_requests/#{id}/notes", body: { body: note })
|
97
97
|
end
|
98
98
|
|
99
99
|
# Adds a comment to a merge request.
|
@@ -102,13 +102,13 @@ class Gitlab::Client
|
|
102
102
|
# Gitlab.edit_merge_request_comment(5, 1,2, "Awesome merge!")
|
103
103
|
# Gitlab.edit_merge_request_comment('gitlab', 1, 2, "Awesome merge!")
|
104
104
|
#
|
105
|
-
# @param [Integer] project The ID of a project.
|
105
|
+
# @param [Integer, String] project The ID or name of a project.
|
106
106
|
# @param [Integer] id The ID of a merge request.
|
107
107
|
# @param [Integer] id The ID of the merge-request comment
|
108
108
|
# @param [String] note The content of a comment.
|
109
109
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
|
110
110
|
def edit_merge_request_comment(project, id, note_id , note)
|
111
|
-
put("/projects/#{project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note })
|
111
|
+
put("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note })
|
112
112
|
end
|
113
113
|
|
114
114
|
# Deletes a comment from a merge request.
|
@@ -117,28 +117,28 @@ class Gitlab::Client
|
|
117
117
|
# Gitlab.delete_merge_request_comment(5, 1,2)
|
118
118
|
# Gitlab.delete_merge_request_comment('gitlab', 1, 2)
|
119
119
|
#
|
120
|
-
# @param [Integer] project The ID of a project.
|
120
|
+
# @param [Integer, String] project The ID or name of a project.
|
121
121
|
# @param [Integer] id The ID of a merge request.
|
122
122
|
# @param [Integer] id The ID of the merge-request comment
|
123
123
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
|
124
124
|
def delete_merge_request_comment(project, id, note_id)
|
125
|
-
delete("/projects/#{project}/merge_requests/#{id}/notes/#{note_id}")
|
125
|
+
delete("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}")
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
# Gets the comments on a merge request.
|
129
129
|
#
|
130
130
|
# @example
|
131
131
|
# Gitlab.merge_request_comments(5, 1)
|
132
132
|
# Gitlab.merge_request_comments(5, 1, { per_page: 10, page: 2 })
|
133
133
|
#
|
134
|
-
# @param [Integer] project The ID of a project.
|
134
|
+
# @param [Integer, String] project The ID or name of a project.
|
135
135
|
# @param [Integer] id The ID of a merge request.
|
136
136
|
# @param [Hash] options A customizable set of options.
|
137
137
|
# @option options [Integer] :page The page number.
|
138
138
|
# @option options [Integer] :per_page The number of results per page.
|
139
139
|
# @return [Gitlab::ObjectifiedHash] The merge request's comments.
|
140
140
|
def merge_request_comments(project, id, options={})
|
141
|
-
get("/projects/#{project}/merge_requests/#{id}/notes", query: options)
|
141
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/notes", query: options)
|
142
142
|
end
|
143
143
|
|
144
144
|
# Gets the changes of a merge request.
|
@@ -146,11 +146,11 @@ class Gitlab::Client
|
|
146
146
|
# @example
|
147
147
|
# Gitlab.merge_request_changes(5, 1)
|
148
148
|
#
|
149
|
-
# @param [Integer] project The ID of a project.
|
149
|
+
# @param [Integer, String] project The ID or name of a project.
|
150
150
|
# @param [Integer] id The ID of a merge request.
|
151
151
|
# @return [Gitlab::ObjectifiedHash] The merge request's changes.
|
152
152
|
def merge_request_changes(project, id)
|
153
|
-
get("/projects/#{project}/
|
153
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/changes")
|
154
154
|
end
|
155
155
|
|
156
156
|
# Gets the commits of a merge request.
|
@@ -158,11 +158,48 @@ class Gitlab::Client
|
|
158
158
|
# @example
|
159
159
|
# Gitlab.merge_request_commits(5, 1)
|
160
160
|
#
|
161
|
-
# @param [Integer] project The ID of a project.
|
161
|
+
# @param [Integer, String] project The ID or name of a project.
|
162
162
|
# @param [Integer] id The ID of a merge request.
|
163
163
|
# @return [Array<Gitlab::ObjectifiedHash>] The merge request's commits.
|
164
164
|
def merge_request_commits(project, id)
|
165
|
-
get("/projects/#{project}/
|
165
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/commits")
|
166
|
+
end
|
167
|
+
|
168
|
+
# List issues that will close on merge
|
169
|
+
#
|
170
|
+
# @example
|
171
|
+
# Gitlab.merge_request_closes_issues(5, 1)
|
172
|
+
#
|
173
|
+
# @param [Integer] project The ID of a project
|
174
|
+
# @param [Integer] iid The internal ID of a merge request
|
175
|
+
def merge_request_closes_issues(project_id, merge_request_iid)
|
176
|
+
get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
|
177
|
+
end
|
178
|
+
|
179
|
+
# Subscribes to a merge request.
|
180
|
+
#
|
181
|
+
# @example
|
182
|
+
# Gitlab.subscribe_to_merge_request(5, 1)
|
183
|
+
# Gitlab.subscribe_to_merge_request('gitlab', 1)
|
184
|
+
#
|
185
|
+
# @param [Integer, String] project The ID or name of a project.
|
186
|
+
# @param [Integer] id The ID of a merge request.
|
187
|
+
# @return [Gitlab::ObjectifiedHash] Information about subscribed merge request.
|
188
|
+
def subscribe_to_merge_request(project, id)
|
189
|
+
post("/projects/#{url_encode project}/merge_requests/#{id}/subscribe")
|
190
|
+
end
|
191
|
+
|
192
|
+
# Unsubscribes from a merge request.
|
193
|
+
#
|
194
|
+
# @example
|
195
|
+
# Gitlab.unsubscribe_from_merge_request(5, 1)
|
196
|
+
# Gitlab.unsubscribe_from_merge_request('gitlab', 1)
|
197
|
+
#
|
198
|
+
# @param [Integer, String] project The ID or name of a project.
|
199
|
+
# @param [Integer] id The ID of a merge request.
|
200
|
+
# @return [Gitlab::ObjectifiedHash] Information about unsubscribed merge request.
|
201
|
+
def unsubscribe_from_merge_request(project, id)
|
202
|
+
post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe")
|
166
203
|
end
|
167
204
|
end
|
168
205
|
end
|