gitlab 5.1.0 → 6.0.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +1 -0
- data/lib/gitlab/cli.rb +3 -2
- data/lib/gitlab/cli_helpers.rb +1 -0
- data/lib/gitlab/client/commits.rb +4 -4
- data/lib/gitlab/client/container_registry.rb +7 -2
- data/lib/gitlab/client/groups.rb +12 -4
- data/lib/gitlab/client/projects.rb +4 -0
- data/lib/gitlab/client/remote_mirrors.rb +39 -0
- data/lib/gitlab/configuration.rb +2 -1
- data/lib/gitlab/request.rb +22 -1
- data/lib/gitlab/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87d3a45a149b5716785aeae8de09e610054957164a6ab6fd72a78ccb61ddc4e
|
4
|
+
data.tar.gz: a1b09933c6bb1f55a7d3036b85fec73c3a5563879cf7685b9d0671733454b66d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfab31240d5cbd79d7f620044f7693dae8800bc9c6f725e4732bd1332df2088108c16576c9c568693a248cfc57986c3ba6169e1d29f8590dee9bb624fb77c448
|
7
|
+
data.tar.gz: efe36ef14a181fe06deed1065d0cbbca162af6efc290fd80378c12e70b9d2ad0a84ca11e8a5f56667268f8345713af93e43e840c826d9c935de753600ae4aacf
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -42,6 +42,7 @@ Gitlab.configure do |config|
|
|
42
42
|
# Optional
|
43
43
|
# config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'
|
44
44
|
# config.sudo = 'user' # username for sudo mode, default: nil
|
45
|
+
# config.body_as_json = false # use application/json for all requests with a body, default: false
|
45
46
|
end
|
46
47
|
```
|
47
48
|
|
data/lib/gitlab/cli.rb
CHANGED
@@ -16,12 +16,13 @@ class Gitlab::CLI
|
|
16
16
|
#
|
17
17
|
# @param [Array] args The command and it's optional arguments.
|
18
18
|
def self.start(args)
|
19
|
+
args_dup = args.dup
|
19
20
|
command = begin
|
20
|
-
|
21
|
+
args_dup.shift.strip
|
21
22
|
rescue StandardError
|
22
23
|
'help'
|
23
24
|
end
|
24
|
-
run(command,
|
25
|
+
run(command, args_dup)
|
25
26
|
end
|
26
27
|
|
27
28
|
# Processes a CLI command and outputs a result to the stream (stdout).
|
data/lib/gitlab/cli_helpers.rb
CHANGED
@@ -172,14 +172,14 @@ class Gitlab::Client
|
|
172
172
|
|
173
173
|
# Creates a single commit with one or more changes
|
174
174
|
#
|
175
|
-
# @see https://docs.gitlab.com/
|
175
|
+
# @see https://docs.gitlab.com/api/commits/#create-a-commit-with-multiple-files-and-actions
|
176
176
|
# Introduced in Gitlab 8.13
|
177
177
|
#
|
178
178
|
# @example
|
179
|
-
#
|
180
|
-
#
|
179
|
+
# Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'create', file_path: '/foo.txt', content: 'bar'}])
|
180
|
+
# Gitlab.create_commit(2726132, 'master', 'refactors everything', [{action: 'delete', file_path: '/foo.txt'}])
|
181
181
|
#
|
182
|
-
# @param
|
182
|
+
# @param [Integer, String] project The ID or name of a project.
|
183
183
|
# @param [String] branch the branch name you wish to commit to
|
184
184
|
# @param [String] message the commit message
|
185
185
|
# @param [Array[Hash]] An array of action hashes to commit as a batch. See the next table for what attributes it can take.
|
@@ -10,9 +10,14 @@ class Gitlab::Client
|
|
10
10
|
# Gitlab.registry_repositories(5)
|
11
11
|
#
|
12
12
|
# @param [Integer, String] project The ID or name of a project.
|
13
|
+
# @param [Hash] options A customizable set of options.
|
14
|
+
# @option options [Boolean] :tags Return tags array in the response.
|
15
|
+
# @option options [Boolean] :tags_count Return tags count in the response.
|
16
|
+
# @option options [Integer] :page The page number.
|
17
|
+
# @option options [Integer] :per_page The number of results per page.
|
13
18
|
# @return [Array<Gitlab::ObjectifiedHash>] Returns list of registry repositories in a project.
|
14
|
-
def registry_repositories(project)
|
15
|
-
get("/projects/#{url_encode project}/registry/repositories")
|
19
|
+
def registry_repositories(project, options = {})
|
20
|
+
get("/projects/#{url_encode project}/registry/repositories", query: options)
|
16
21
|
end
|
17
22
|
|
18
23
|
# Delete a repository in registry.
|
data/lib/gitlab/client/groups.rb
CHANGED
@@ -148,26 +148,34 @@ class Gitlab::Client
|
|
148
148
|
#
|
149
149
|
# @example
|
150
150
|
# Gitlab.add_group_member(1, 2, 40)
|
151
|
+
# Gitlab.add_group_member(1, 2, 40, member_role_id: 5)
|
151
152
|
#
|
152
153
|
# @param [Integer] team_id The group id to add a member to.
|
153
154
|
# @param [Integer] user_id The user id of the user to add to the team.
|
154
155
|
# @param [Integer] access_level Project access level.
|
156
|
+
# @param [Hash] options A customizable set of options.
|
157
|
+
# @option options [Integer] :member_role_id The id of a custom member role.
|
155
158
|
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
156
|
-
def add_group_member(team_id, user_id, access_level)
|
157
|
-
|
159
|
+
def add_group_member(team_id, user_id, access_level, options = {})
|
160
|
+
body = { user_id: user_id, access_level: access_level }.merge(options)
|
161
|
+
post("/groups/#{url_encode team_id}/members", body: body)
|
158
162
|
end
|
159
163
|
|
160
164
|
# Edit a user of a group.
|
161
165
|
#
|
162
166
|
# @example
|
163
167
|
# Gitlab.edit_group_member(1, 2, 40)
|
168
|
+
# Gitlab.edit_group_member(1, 2, 40, member_role_id: 5)
|
164
169
|
#
|
165
170
|
# @param [Integer] team_id The group id of member to edit.
|
166
171
|
# @param [Integer] user_id The user id of the user to edit.
|
167
172
|
# @param [Integer] access_level Project access level.
|
173
|
+
# @param [Hash] options A customizable set of options.
|
174
|
+
# @option options [Integer] :member_role_id The id of a custom member role.
|
168
175
|
# @return [Gitlab::ObjectifiedHash] Information about edited team member.
|
169
|
-
def edit_group_member(team_id, user_id, access_level)
|
170
|
-
|
176
|
+
def edit_group_member(team_id, user_id, access_level, options = {})
|
177
|
+
body = { access_level: access_level }.merge(options)
|
178
|
+
put("/groups/#{url_encode team_id}/members/#{user_id}", body: body)
|
171
179
|
end
|
172
180
|
|
173
181
|
# Removes user from user group.
|
@@ -138,12 +138,14 @@ class Gitlab::Client
|
|
138
138
|
# @example
|
139
139
|
# Gitlab.add_team_member('gitlab', 2, 40)
|
140
140
|
# Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"})
|
141
|
+
# Gitlab.add_team_member('gitlab', 2, 40, { member_role_id: 5 })
|
141
142
|
#
|
142
143
|
# @param [Integer, String] project The ID or path of a project.
|
143
144
|
# @param [Integer] id The ID of a user.
|
144
145
|
# @param [Integer] access_level The access level to project.
|
145
146
|
# @param [Hash] options A customizable set of options.
|
146
147
|
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
148
|
+
# @option options [Integer] :member_role_id The id of a custom member role.
|
147
149
|
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
148
150
|
def add_team_member(project, id, access_level, options = {})
|
149
151
|
body = { user_id: id, access_level: access_level }.merge(options)
|
@@ -155,12 +157,14 @@ class Gitlab::Client
|
|
155
157
|
# @example
|
156
158
|
# Gitlab.edit_team_member('gitlab', 3, 20)
|
157
159
|
# Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"})
|
160
|
+
# Gitlab.edit_team_member('gitlab', 3, 20, { member_role_id: 5 })
|
158
161
|
#
|
159
162
|
# @param [Integer, String] project The ID or path of a project.
|
160
163
|
# @param [Integer] id The ID of a user.
|
161
164
|
# @param [Integer] access_level The access level to project.
|
162
165
|
# @param [Hash] options A customizable set of options.
|
163
166
|
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
167
|
+
# @option options [Integer] :member_role_id The id of a custom member role.
|
164
168
|
# @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
|
165
169
|
def edit_team_member(project, id, access_level, options = {})
|
166
170
|
body = { access_level: access_level }.merge(options)
|
@@ -16,6 +16,19 @@ class Gitlab::Client
|
|
16
16
|
get("/projects/#{url_encode project}/remote_mirrors")
|
17
17
|
end
|
18
18
|
|
19
|
+
# Get a specific remote mirror.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# Gitlab.remote_mirror(42, 1234)
|
23
|
+
#
|
24
|
+
# @param [Integer, String] project The ID or path of a project.
|
25
|
+
# @param [Integer] id The ID of the remote mirror.
|
26
|
+
#
|
27
|
+
# @return [Gitlab::ObjectifiedHash] Information about the specified remote mirror.
|
28
|
+
def remote_mirror(project, id)
|
29
|
+
get("/projects/#{url_encode project}/remote_mirrors/#{id}")
|
30
|
+
end
|
31
|
+
|
19
32
|
# Create a remote mirror
|
20
33
|
#
|
21
34
|
# @example
|
@@ -47,5 +60,31 @@ class Gitlab::Client
|
|
47
60
|
def edit_remote_mirror(project, id, options = {})
|
48
61
|
put("/projects/#{url_encode project}/remote_mirrors/#{id}", body: options)
|
49
62
|
end
|
63
|
+
|
64
|
+
# Delete a remote mirror.
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# Gitlab.delete_remote_mirror(42, 1234)
|
68
|
+
#
|
69
|
+
# @param [Integer, String] project The ID or path of a project.
|
70
|
+
# @param [Integer] id The ID of the remote mirror.
|
71
|
+
#
|
72
|
+
# @return [Gitlab::ObjectifiedHash]
|
73
|
+
def delete_remote_mirror(project, id)
|
74
|
+
delete("/projects/#{url_encode project}/remote_mirrors/#{id}")
|
75
|
+
end
|
76
|
+
|
77
|
+
# Force push mirror update.
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# Gitlab.sync_remote_mirror(42, 1234)
|
81
|
+
#
|
82
|
+
# @param [Integer, String] project The ID or path of a project.
|
83
|
+
# @param [Integer] id The ID of the remote mirror.
|
84
|
+
#
|
85
|
+
# @return [Gitlab::ObjectifiedHash]
|
86
|
+
def sync_remote_mirror(project, id)
|
87
|
+
post("/projects/#{url_encode project}/remote_mirrors/#{id}/sync")
|
88
|
+
end
|
50
89
|
end
|
51
90
|
end
|
data/lib/gitlab/configuration.rb
CHANGED
@@ -5,7 +5,7 @@ module Gitlab
|
|
5
5
|
# Defines constants and methods related to configuration.
|
6
6
|
module Configuration
|
7
7
|
# An array of valid keys in the options hash when configuring a Gitlab::API.
|
8
|
-
VALID_OPTIONS_KEYS = %i[endpoint private_token user_agent sudo httparty pat_prefix].freeze
|
8
|
+
VALID_OPTIONS_KEYS = %i[endpoint private_token user_agent sudo httparty pat_prefix body_as_json].freeze
|
9
9
|
|
10
10
|
# The user agent that will be sent to the API endpoint if none is set.
|
11
11
|
DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}"
|
@@ -41,6 +41,7 @@ module Gitlab
|
|
41
41
|
self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS'])
|
42
42
|
self.sudo = nil
|
43
43
|
self.user_agent = DEFAULT_USER_AGENT
|
44
|
+
self.body_as_json = false
|
44
45
|
end
|
45
46
|
|
46
47
|
private
|
data/lib/gitlab/request.rb
CHANGED
@@ -12,7 +12,7 @@ module Gitlab
|
|
12
12
|
headers 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'
|
13
13
|
parser(proc { |body, _| parse(body) })
|
14
14
|
|
15
|
-
attr_accessor :private_token, :endpoint, :pat_prefix
|
15
|
+
attr_accessor :private_token, :endpoint, :pat_prefix, :body_as_json
|
16
16
|
|
17
17
|
# Converts the response body to an ObjectifiedHash.
|
18
18
|
def self.parse(body)
|
@@ -49,6 +49,8 @@ module Gitlab
|
|
49
49
|
params[:headers].merge!(authorization_header)
|
50
50
|
end
|
51
51
|
|
52
|
+
jsonify_body_content(params) if body_as_json
|
53
|
+
|
52
54
|
retries_left = params[:ratelimit_retries] || 3
|
53
55
|
begin
|
54
56
|
response = self.class.send(method, endpoint + path, params)
|
@@ -114,5 +116,24 @@ module Gitlab
|
|
114
116
|
def httparty_config(options)
|
115
117
|
options.merge!(httparty) if httparty
|
116
118
|
end
|
119
|
+
|
120
|
+
# Handle 'body_as_json' configuration option
|
121
|
+
# Modifies passed params in place.
|
122
|
+
def jsonify_body_content(params)
|
123
|
+
# Only modify the content type if there is a body to process AND multipath
|
124
|
+
# was not explicitly requested. There are no uses of multipart in this code
|
125
|
+
# today, but file upload methods require it and someone might be manually
|
126
|
+
# crafting a post call with it:
|
127
|
+
return unless params[:body] && params[:multipart] != true
|
128
|
+
|
129
|
+
# If the caller explicitly requested a Content-Type during the call, assume
|
130
|
+
# they know best and have formatted the body as required:
|
131
|
+
return if params[:headers]&.key?('Content-Type')
|
132
|
+
|
133
|
+
# If we make it here, then we assume it is safe to JSON encode the body:
|
134
|
+
params[:headers] ||= {}
|
135
|
+
params[:headers]['Content-Type'] = 'application/json'
|
136
|
+
params[:body] = params[:body].to_json
|
137
|
+
end
|
117
138
|
end
|
118
139
|
end
|
data/lib/gitlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nihad Abbasov
|
8
8
|
- Sean Edge
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: base64
|
@@ -199,7 +199,7 @@ metadata:
|
|
199
199
|
bug_tracker_uri: https://github.com/NARKOZ/gitlab/issues
|
200
200
|
changelog_uri: https://github.com/NARKOZ/gitlab/releases
|
201
201
|
funding_uri: https://github.com/NARKOZ/SponsorMe
|
202
|
-
post_install_message:
|
202
|
+
post_install_message:
|
203
203
|
rdoc_options: []
|
204
204
|
require_paths:
|
205
205
|
- lib
|
@@ -207,15 +207,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
207
|
requirements:
|
208
208
|
- - ">="
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: '3.
|
210
|
+
version: '3.2'
|
211
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - ">="
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.5.
|
218
|
-
signing_key:
|
217
|
+
rubygems_version: 3.5.22
|
218
|
+
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: A Ruby wrapper and CLI for the GitLab API
|
221
221
|
test_files: []
|