gitlab 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +33 -0
- data/.travis.yml +8 -3
- data/README.md +7 -7
- data/Rakefile +11 -3
- data/gitlab.gemspec +11 -11
- data/lib/gitlab.rb +2 -2
- data/lib/gitlab/api.rb +2 -1
- data/lib/gitlab/cli.rb +2 -6
- data/lib/gitlab/cli_helpers.rb +18 -20
- data/lib/gitlab/client.rb +8 -5
- data/lib/gitlab/client/branches.rb +4 -4
- data/lib/gitlab/client/build_variables.rb +64 -2
- data/lib/gitlab/client/deployments.rb +32 -0
- data/lib/gitlab/client/groups.rb +49 -0
- data/lib/gitlab/client/issues.rb +71 -0
- data/lib/gitlab/client/merge_requests.rb +1 -0
- data/lib/gitlab/client/pipeline_schedules.rb +133 -0
- data/lib/gitlab/client/pipeline_triggers.rb +2 -2
- data/lib/gitlab/client/projects.rb +1 -1
- data/lib/gitlab/client/repository_files.rb +2 -2
- data/lib/gitlab/client/users.rb +5 -5
- data/lib/gitlab/configuration.rb +2 -2
- data/lib/gitlab/error.rb +10 -2
- data/lib/gitlab/file_response.rb +1 -1
- data/lib/gitlab/help.rb +5 -6
- data/lib/gitlab/page_links.rb +2 -2
- data/lib/gitlab/request.rb +34 -50
- data/lib/gitlab/shell.rb +5 -8
- data/lib/gitlab/version.rb +1 -1
- data/spec/fixtures/deployment.json +57 -0
- data/spec/fixtures/deployments.json +116 -0
- data/spec/fixtures/group_edit.json +14 -0
- data/spec/fixtures/group_subgroups.json +16 -0
- data/spec/fixtures/pipeline_schedule.json +32 -0
- data/spec/fixtures/pipeline_schedule_create.json +21 -0
- data/spec/fixtures/pipeline_schedule_update.json +26 -0
- data/spec/fixtures/pipeline_schedule_variable.json +5 -0
- data/spec/fixtures/pipeline_schedule_variable_update.json +5 -0
- data/spec/fixtures/pipeline_schedules.json +22 -0
- data/spec/gitlab/api_spec.rb +11 -0
- data/spec/gitlab/cli_helpers_spec.rb +14 -15
- data/spec/gitlab/cli_spec.rb +11 -11
- data/spec/gitlab/client/award_emojis_spec.rb +55 -55
- data/spec/gitlab/client/boards_spec.rb +12 -12
- data/spec/gitlab/client/branches_spec.rb +22 -22
- data/spec/gitlab/client/build_variables_spec.rb +93 -10
- data/spec/gitlab/client/builds_spec.rb +36 -36
- data/spec/gitlab/client/commits_spec.rb +21 -21
- data/spec/gitlab/client/deployments_spec.rb +38 -0
- data/spec/gitlab/client/environments_spec.rb +18 -18
- data/spec/gitlab/client/groups_spec.rb +73 -22
- data/spec/gitlab/client/issues_spec.rb +121 -22
- data/spec/gitlab/client/jobs_spec.rb +13 -13
- data/spec/gitlab/client/keys_spec.rb +2 -2
- data/spec/gitlab/client/labels_spec.rb +12 -12
- data/spec/gitlab/client/merge_requests_spec.rb +23 -23
- data/spec/gitlab/client/milestones_spec.rb +12 -12
- data/spec/gitlab/client/namespaces_spec.rb +3 -3
- data/spec/gitlab/client/notes_spec.rb +40 -40
- data/spec/gitlab/client/pipeline_schedules_spec.rb +158 -0
- data/spec/gitlab/client/pipeline_triggers_spec.rb +17 -17
- data/spec/gitlab/client/pipelines_spec.rb +22 -22
- data/spec/gitlab/client/projects_spec.rb +75 -75
- data/spec/gitlab/client/repositories_spec.rb +16 -16
- data/spec/gitlab/client/repository_files_spec.rb +10 -10
- data/spec/gitlab/client/runners_spec.rb +20 -22
- data/spec/gitlab/client/services_spec.rb +6 -6
- data/spec/gitlab/client/snippets_spec.rb +12 -12
- data/spec/gitlab/client/system_hooks_spec.rb +12 -12
- data/spec/gitlab/client/tags_spec.rb +19 -20
- data/spec/gitlab/client/todos_spec.rb +12 -12
- data/spec/gitlab/client/users_spec.rb +49 -49
- data/spec/gitlab/error_spec.rb +50 -23
- data/spec/gitlab/file_response_spec.rb +6 -6
- data/spec/gitlab/help_spec.rb +5 -5
- data/spec/gitlab/objectified_hash_spec.rb +8 -8
- data/spec/gitlab/page_links_spec.rb +1 -1
- data/spec/gitlab/paginated_response_spec.rb +4 -4
- data/spec/gitlab/request_spec.rb +19 -19
- data/spec/gitlab/shell_spec.rb +12 -12
- data/spec/gitlab_spec.rb +13 -14
- data/spec/spec_helper.rb +10 -45
- metadata +46 -3
@@ -0,0 +1,32 @@
|
|
1
|
+
class Gitlab::Client
|
2
|
+
# Defines methods related to deployments.
|
3
|
+
# @see https://docs.gitlab.com/ce/api/deployments.html
|
4
|
+
module Deployments
|
5
|
+
# Gets a list of project deployments.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# Gitlab.deployments(5)
|
9
|
+
# Gitlab.deployments(5, { per_page: 10, page: 2 })
|
10
|
+
#
|
11
|
+
# @param [Integer, String] project The ID or name of a project.
|
12
|
+
# @param [Hash] options A customizable set of options.
|
13
|
+
# @option options [Integer] :page The page number.
|
14
|
+
# @option options [Integer] :per_page The number of results per page.
|
15
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
16
|
+
def deployments(project, options={})
|
17
|
+
get("/projects/#{url_encode project}/deployments", query: options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Gets a single deployment.
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# Gitlab.deployment(5, 36)
|
24
|
+
#
|
25
|
+
# @param [Integer, String] project The ID or name of a project.
|
26
|
+
# @param [Integer] id The ID of an deployment.
|
27
|
+
# @return [Gitlab::ObjectifiedHash]
|
28
|
+
def deployment(project, id)
|
29
|
+
get("/projects/#{url_encode project}/deployments/#{id}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/gitlab/client/groups.rb
CHANGED
@@ -66,6 +66,18 @@ class Gitlab::Client
|
|
66
66
|
get("/groups/#{id}/members", query: options)
|
67
67
|
end
|
68
68
|
|
69
|
+
# Get details of a single group member.
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
# Gitlab.group_member(1, 10)
|
73
|
+
#
|
74
|
+
# @param [Integer] team_id The ID of the group to find a member in.
|
75
|
+
# @param [Integer] user_id The user id of the member to find.
|
76
|
+
# @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
|
77
|
+
def group_member(team_id, user_id)
|
78
|
+
get("/groups/#{team_id}/members/#{user_id}")
|
79
|
+
end
|
80
|
+
|
69
81
|
# Adds a user to group.
|
70
82
|
#
|
71
83
|
# @example
|
@@ -140,5 +152,42 @@ class Gitlab::Client
|
|
140
152
|
def group_projects(id, options={})
|
141
153
|
get("/groups/#{id}/projects", query: options)
|
142
154
|
end
|
155
|
+
|
156
|
+
# Get a list of subgroups under a group
|
157
|
+
# @example
|
158
|
+
# Gitlab.group_subgroups(1)
|
159
|
+
#
|
160
|
+
# @param [Integer] id the ID of a group
|
161
|
+
# @param [Hash] options A customizable set of options.
|
162
|
+
# @option options [String] :skip_groups Skip the group IDs passed.
|
163
|
+
# @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
|
164
|
+
# @option options [String] :search Return the list of authorized groups matching the search criteria.
|
165
|
+
# @option options [String] :order_by Order groups by name or path. Default is name.
|
166
|
+
# @option options [String] :sort Order groups in asc or desc order. Default is asc.
|
167
|
+
# @option options [String] :statistics Include group statistics (admins only).
|
168
|
+
# @option options [String] :owned Limit to groups owned by the current user.
|
169
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
|
170
|
+
def group_subgroups(id, options={})
|
171
|
+
get("/groups/#{id}/subgroups", query: options)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Updates an existing group.
|
175
|
+
#
|
176
|
+
# @example
|
177
|
+
# Gitlab.edit_group(42)
|
178
|
+
# Gitlab.edit_group(42, { name: 'Group Name' })
|
179
|
+
#
|
180
|
+
# @param [Integer] group The ID.
|
181
|
+
# @param [Hash] options A customizable set of options
|
182
|
+
# @option options [String] :name The name of the group.
|
183
|
+
# @option options [String] :path The path of the group.
|
184
|
+
# @option options [String] :description The description of the group.
|
185
|
+
# @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
|
186
|
+
# @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
|
187
|
+
# @option options [String] :request_access_enabled Allow users to request member access.
|
188
|
+
# @return [Gitlab::ObjectifiedHash] Information about the edited group.
|
189
|
+
def edit_group(id, options={})
|
190
|
+
put("/groups/#{id}", body: options)
|
191
|
+
end
|
143
192
|
end
|
144
193
|
end
|
data/lib/gitlab/client/issues.rb
CHANGED
@@ -133,5 +133,76 @@ class Gitlab::Client
|
|
133
133
|
def delete_issue(project, id)
|
134
134
|
delete("/projects/#{url_encode project}/issues/#{id}")
|
135
135
|
end
|
136
|
+
|
137
|
+
# Move an issue.
|
138
|
+
#
|
139
|
+
# @example
|
140
|
+
# Gitlab.move_issue(3, 42, { to_project_id: '4' })
|
141
|
+
#
|
142
|
+
# @param [Integer, String] project The ID or name of a project.
|
143
|
+
# @param [Integer] id The ID of an issue.
|
144
|
+
# @option options [String] :to_project_id The ID of the new project.
|
145
|
+
# @return [Gitlab::ObjectifiedHash] Information about moved issue.
|
146
|
+
def move_issue(project, id, options={})
|
147
|
+
post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Sets an estimated time of work for an issue.
|
151
|
+
#
|
152
|
+
# @example
|
153
|
+
# Gitlab.estimate_time_of_issue(3, 42, '3h30m')
|
154
|
+
#
|
155
|
+
# @param [Integer, String] project The ID or name of a project.
|
156
|
+
# @param [Integer] id The ID of an issue.
|
157
|
+
# @param [String] duration The duration in human format. e.g: 3h30m
|
158
|
+
def estimate_time_of_issue(project, id, duration)
|
159
|
+
post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
|
160
|
+
end
|
161
|
+
|
162
|
+
# Resets the estimated time for an issue to 0 seconds.
|
163
|
+
#
|
164
|
+
# @example
|
165
|
+
# Gitlab.reset_time_estimate_of_issue(3, 42)
|
166
|
+
#
|
167
|
+
# @param [Integer, String] project The ID or name of a project.
|
168
|
+
# @param [Integer] id The ID of an issue.
|
169
|
+
def reset_time_estimate_of_issue(project, id)
|
170
|
+
post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
|
171
|
+
end
|
172
|
+
|
173
|
+
# Adds spent time for an issue
|
174
|
+
#
|
175
|
+
# @example
|
176
|
+
# Gitlab.estimate_time_of_issue(3, 42, '3h30m')
|
177
|
+
#
|
178
|
+
# @param [Integer, String] project The ID or name of a project.
|
179
|
+
# @param [Integer] id The ID of an issue.
|
180
|
+
# @param [String] duration The time spent in human format. e.g: 3h30m
|
181
|
+
def add_time_spent_on_issue(project, id, duration)
|
182
|
+
post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) })
|
183
|
+
end
|
184
|
+
|
185
|
+
# Resets the total spent time for this issue to 0 seconds.
|
186
|
+
#
|
187
|
+
# @example
|
188
|
+
# Gitlab.reset_time_spent_on_issue(3, 42)
|
189
|
+
#
|
190
|
+
# @param [Integer, String] project The ID or name of a project.
|
191
|
+
# @param [Integer] id The ID of an issue.
|
192
|
+
def reset_time_spent_on_issue(project, id)
|
193
|
+
post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
|
194
|
+
end
|
195
|
+
|
196
|
+
# Get time tracking stats for an issue
|
197
|
+
#
|
198
|
+
# @example
|
199
|
+
# @gitlab.time_stats_for_issue(3, 42)
|
200
|
+
#
|
201
|
+
# @param [Integer, String] project The ID or name of a project.
|
202
|
+
# @param [Integer] id The ID of an issue.
|
203
|
+
def time_stats_for_issue(project, id)
|
204
|
+
get("/projects/#{url_encode project}/issues/#{id}/time_stats")
|
205
|
+
end
|
206
|
+
|
136
207
|
end
|
137
208
|
end
|
@@ -44,6 +44,7 @@ class Gitlab::Client
|
|
44
44
|
# @option options [String] :target_branch (required) The target branch name.
|
45
45
|
# @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
|
46
46
|
# @option options [Integer] :target_project_id (optional) The target project ID.
|
47
|
+
# @option options [String] :labels (optional) Labels as a comma-separated list.
|
47
48
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
|
48
49
|
def create_merge_request(project, title, options={})
|
49
50
|
body = { title: title }.merge(options)
|
@@ -0,0 +1,133 @@
|
|
1
|
+
class Gitlab::Client
|
2
|
+
# Defines methods related to pipeline schedules.
|
3
|
+
# @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
|
4
|
+
module PipelineSchedules
|
5
|
+
# Gets a list of project pipeline schedules.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# Gitlab.pipeline_schedules(5)
|
9
|
+
# Gitlab.pipeline_schedules(5, { scope: 'active' })
|
10
|
+
#
|
11
|
+
# @param [Integer, String] project the ID or name of a project.
|
12
|
+
# @param [Hash] options A customizable set of options.
|
13
|
+
# @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
|
+
def pipeline_schedules(project, options={})
|
16
|
+
get("/projects/#{url_encode project}/pipeline_schedules", query: options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Gets a single pipeline schedule.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# Gitlab.pipeline_schedule(5, 3)
|
23
|
+
#
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
25
|
+
# @param [Integer] id The ID of the pipeline schedule.
|
26
|
+
# @return [Gitlab::ObjectifiedHash]
|
27
|
+
def pipeline_schedule(project, id)
|
28
|
+
get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create a pipeline schedule.
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# Gitlab.create_pipeline_schedule(5, { description: 'example' })
|
35
|
+
#
|
36
|
+
# @param [Integer, String] project The ID or name of a project.
|
37
|
+
# @param [Hash] options A customizable set of options.
|
38
|
+
# @option options [String] :description The description of pipeline scehdule.
|
39
|
+
# @option options [String] :ref The branch/tag name will be triggered.
|
40
|
+
# @option options [String] :cron The cron (e.g. 0 1 * * *).
|
41
|
+
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
|
42
|
+
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
43
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
44
|
+
def create_pipeline_schedule(project, options={})
|
45
|
+
post("/projects/#{url_encode project}/pipeline_schedules", query: options)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Updates the pipeline schedule of a project.
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# Gitlab.edit_pipeline_schedule(3, 2, { description: 'example2' })
|
52
|
+
#
|
53
|
+
# @param [Integer, String] project The ID or name of a project.
|
54
|
+
# @param [Integer] The pipeline schedule ID.
|
55
|
+
# @param [Hash] options A customizable set of options.
|
56
|
+
# @option options [String] :description The description of pipeline scehdule.
|
57
|
+
# @option options [String] :ref The branch/tag name will be triggered.
|
58
|
+
# @option options [String] :cron The cron (e.g. 0 1 * * *).
|
59
|
+
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
|
60
|
+
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
61
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
|
62
|
+
def edit_pipeline_schedule(project, pipeline_schedule_id, options={})
|
63
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", query: options)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Take ownership of a pipeline schedule.
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# Gitlab.pipeline_schedule_take_ownership(5, 1)
|
70
|
+
#
|
71
|
+
# @param [Integer, String] project The ID or name of a project.
|
72
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
73
|
+
# @return [Gitlab::ObjectifiedHash] The updated pipeline schedule.
|
74
|
+
def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
|
75
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
|
76
|
+
end
|
77
|
+
|
78
|
+
# Delete a pipeline schedule.
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Gitlab.delete_pipeline_schedule(5, 1)
|
82
|
+
#
|
83
|
+
# @param [Integer, String] project The ID or name of a project.
|
84
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
85
|
+
# @return [Gitlab::ObjectifiedHash] The deleted pipeline schedule.
|
86
|
+
def delete_pipeline_schedule(project, pipeline_schedule_id)
|
87
|
+
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}")
|
88
|
+
end
|
89
|
+
|
90
|
+
# Create a pipeline schedule variable.
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
# Gitlab.create_pipeline_schedule_variable(5, 1, { key: 'foo', value: 'bar' })
|
94
|
+
#
|
95
|
+
# @param [Integer, String] project The ID or name of a project.
|
96
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
97
|
+
# @param [Hash] options A customizable set of options.
|
98
|
+
# @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed.
|
99
|
+
# @option options [String] :value The value of a variable
|
100
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
|
101
|
+
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options={})
|
102
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", query: options)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Updates the variable of a pipeline schedule.
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# Gitlab.edit_pipeline_schedule_variable(3, 2, "foo" { value: 'bar' })
|
109
|
+
#
|
110
|
+
# @param [Integer, String] project The ID or name of a project.
|
111
|
+
# @param [Integer] The pipeline schedule ID.
|
112
|
+
# @param [String] The key of a variable.
|
113
|
+
# @param [Hash] options A customizable set of options.
|
114
|
+
# @option options [String] :value The value of a variable.
|
115
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
|
116
|
+
def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={})
|
117
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", query: options)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Delete the variable of a pipeline schedule
|
121
|
+
#
|
122
|
+
# @example
|
123
|
+
# Gitlab.delete_pipeline_schedule_variable(3, 2, "foo")
|
124
|
+
#
|
125
|
+
# @param [Integer, String] project The ID or name of a project.
|
126
|
+
# @param [Integer] The pipeline schedule ID.
|
127
|
+
# @param [String] The key of a variable.
|
128
|
+
# @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
|
129
|
+
def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={})
|
130
|
+
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -80,8 +80,8 @@ class Gitlab::Client
|
|
80
80
|
# Run the given project pipeline trigger.
|
81
81
|
#
|
82
82
|
# @example
|
83
|
-
# Gitlab.
|
84
|
-
# Gitlab.
|
83
|
+
# Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master')
|
84
|
+
# Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
|
85
85
|
#
|
86
86
|
# @see https://docs.gitlab.com/ce/ci/triggers/README.html
|
87
87
|
#
|
@@ -298,7 +298,7 @@ class Gitlab::Client
|
|
298
298
|
#
|
299
299
|
# @param [Integer] id The ID of a project.
|
300
300
|
# @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
|
301
|
-
def delete_push_rule(id
|
301
|
+
def delete_push_rule(id)
|
302
302
|
delete("/projects/#{url_encode id}/push_rule")
|
303
303
|
end
|
304
304
|
|
@@ -15,7 +15,6 @@ class Gitlab::Client
|
|
15
15
|
# @param [String] ref The name of a repository branch or tag or if not given the default branch.
|
16
16
|
# @return [String]
|
17
17
|
def file_contents(project, filepath, ref='master')
|
18
|
-
ref = URI.encode(ref, /\W/)
|
19
18
|
get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw",
|
20
19
|
query: { ref: ref},
|
21
20
|
format: nil,
|
@@ -95,7 +94,8 @@ class Gitlab::Client
|
|
95
94
|
# @option options [String] :author_email Commit author's email address
|
96
95
|
# @return [Gitlab::ObjectifiedHash]
|
97
96
|
def remove_file(project, path, branch, commit_message, options = {})
|
98
|
-
delete("/projects/#{url_encode project}/repository/files/#{url_encode path}",
|
97
|
+
delete("/projects/#{url_encode project}/repository/files/#{url_encode path}",
|
98
|
+
body: {
|
99
99
|
branch: branch,
|
100
100
|
commit_message: commit_message
|
101
101
|
}.merge(options))
|
data/lib/gitlab/client/users.rb
CHANGED
@@ -49,11 +49,11 @@ class Gitlab::Client
|
|
49
49
|
# @return [Gitlab::ObjectifiedHash] Information about created user.
|
50
50
|
def create_user(*args)
|
51
51
|
options = Hash === args.last ? args.pop : {}
|
52
|
-
if args[2]
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
body = if args[2]
|
53
|
+
{ email: args[0], password: args[1], username: args[2] }
|
54
|
+
else
|
55
|
+
{ email: args[0], password: args[1], name: args[0] }
|
56
|
+
end
|
57
57
|
body.merge!(options)
|
58
58
|
post('/users', body: body)
|
59
59
|
end
|
data/lib/gitlab/configuration.rb
CHANGED
@@ -3,7 +3,7 @@ module Gitlab
|
|
3
3
|
# Defines constants and methods related to configuration.
|
4
4
|
module Configuration
|
5
5
|
# An array of valid keys in the options hash when configuring a Gitlab::API.
|
6
|
-
VALID_OPTIONS_KEYS =
|
6
|
+
VALID_OPTIONS_KEYS = %i(endpoint private_token user_agent sudo httparty).freeze
|
7
7
|
|
8
8
|
# The user agent that will be sent to the API endpoint if none is set.
|
9
9
|
DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}".freeze
|
@@ -48,7 +48,7 @@ module Gitlab
|
|
48
48
|
|
49
49
|
httparty = Gitlab::CLI::Helpers.yaml_load(options)
|
50
50
|
|
51
|
-
raise ArgumentError,
|
51
|
+
raise ArgumentError, 'HTTParty config should be a Hash.' unless httparty.is_a? Hash
|
52
52
|
Gitlab::CLI::Helpers.symbolize_keys httparty
|
53
53
|
end
|
54
54
|
end
|
data/lib/gitlab/error.rb
CHANGED
@@ -16,13 +16,20 @@ module Gitlab
|
|
16
16
|
super(build_error_message)
|
17
17
|
end
|
18
18
|
|
19
|
-
# Status code returned in the
|
19
|
+
# Status code returned in the HTTP response.
|
20
20
|
#
|
21
21
|
# @return [Integer]
|
22
22
|
def response_status
|
23
23
|
@response.code
|
24
24
|
end
|
25
25
|
|
26
|
+
# Body content returned in the HTTP response
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
def response_message
|
30
|
+
@response.parsed_response.message
|
31
|
+
end
|
32
|
+
|
26
33
|
private
|
27
34
|
|
28
35
|
# Human friendly message.
|
@@ -30,7 +37,8 @@ module Gitlab
|
|
30
37
|
# @return [String]
|
31
38
|
def build_error_message
|
32
39
|
parsed_response = @response.parsed_response
|
33
|
-
message = parsed_response.message
|
40
|
+
message = parsed_response.respond_to?(:message) ? parsed_response.message : parsed_response['message']
|
41
|
+
message = parsed_response.respond_to?(:error) ? parsed_response.error : parsed_response['error'] unless message
|
34
42
|
|
35
43
|
"Server responded with code #{@response.code}, message: " \
|
36
44
|
"#{handle_message(message)}. " \
|
data/lib/gitlab/file_response.rb
CHANGED
@@ -39,7 +39,7 @@ module Gitlab
|
|
39
39
|
|
40
40
|
# Parse filename from the 'Content Disposition' header.
|
41
41
|
def parse_headers!(headers)
|
42
|
-
@filename = headers[HEADER_CONTENT_DISPOSITION].split(
|
42
|
+
@filename = headers[HEADER_CONTENT_DISPOSITION].split('filename=')[1]
|
43
43
|
@filename = @filename[1...-1] if @filename[0] == '"' # Unquote filenames
|
44
44
|
end
|
45
45
|
end
|
data/lib/gitlab/help.rb
CHANGED
@@ -33,7 +33,7 @@ module Gitlab::Help
|
|
33
33
|
def ri_cmd
|
34
34
|
which_ri = `which ri`.chomp
|
35
35
|
if which_ri.empty?
|
36
|
-
|
36
|
+
raise "'ri' tool not found in $PATH. Please install it to use the help."
|
37
37
|
end
|
38
38
|
|
39
39
|
which_ri
|
@@ -61,7 +61,7 @@ module Gitlab::Help
|
|
61
61
|
def actions_table(topic=nil)
|
62
62
|
rows = topic ? help_map[topic] : help_map.keys
|
63
63
|
table do |t|
|
64
|
-
t.title = topic ||
|
64
|
+
t.title = topic || 'Help Topics'
|
65
65
|
|
66
66
|
# add_row expects an array and we have strings hence the map.
|
67
67
|
rows.sort.map { |r| [r] }.each_with_index do |row, index|
|
@@ -73,7 +73,7 @@ module Gitlab::Help
|
|
73
73
|
|
74
74
|
# Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd)
|
75
75
|
def namespace(cmd)
|
76
|
-
method_owners.select { |method| method[:name]
|
76
|
+
method_owners.select { |method| method[:name] == cmd }.
|
77
77
|
map { |method| method[:owner] + '.' + method[:name] }.
|
78
78
|
shift
|
79
79
|
end
|
@@ -82,14 +82,13 @@ module Gitlab::Help
|
|
82
82
|
def change_help_output!(cmd, output_str)
|
83
83
|
output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
|
84
84
|
output_str.gsub!(/\,[\s]*/, ' ')
|
85
|
-
|
85
|
+
|
86
86
|
# Ensure @option descriptions are on a single line
|
87
87
|
output_str.gsub!(/\n\[/, " \[")
|
88
88
|
output_str.gsub!(/\s(@)/, "\n@")
|
89
89
|
output_str.gsub!(/(\])\n(\:)/, '\1 \2')
|
90
90
|
output_str.gsub!(/(\:.*)(\n)(.*\.)/, '\1 \3')
|
91
91
|
output_str.gsub!(/\{(.+)\}/, '"{\1}"')
|
92
|
-
|
93
92
|
end
|
94
|
-
end
|
93
|
+
end
|
95
94
|
end
|