gitlab 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gitlab/client/merge_requests.rb +16 -2
- data/lib/gitlab/client/pipeline_schedules.rb +12 -0
- data/lib/gitlab/client/projects.rb +81 -1
- data/lib/gitlab/client.rb +8 -1
- data/lib/gitlab/configuration.rb +2 -1
- data/lib/gitlab/request.rb +12 -3
- data/lib/gitlab/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1453623fe0d87a006492342f5726338aba971afcc6b693295f537a037d7e2e9
|
4
|
+
data.tar.gz: ab5e4e4d81bdeeef8802dc03bc8b7c912c6b41f1d4ac25ab5ca752b4af53121b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54dae253ce896dcbf3e612fdd4bb3e092373557e5959292e5a949108679d4ead1ac69e34e45f9d15c795e826d19b55175ad234598aa68f2e51c8384289af7267
|
7
|
+
data.tar.gz: 14ab36332c58d98f43216df49bfa6e1cbe8aa6a540ef83cb4b1d2090cad66c9eb8351172f1d13feb369f7f32b8d65503094be358d855b1d5636f01418b129f4f
|
@@ -59,6 +59,18 @@ class Gitlab::Client
|
|
59
59
|
get("/projects/#{url_encode project}/merge_requests/#{id}/pipelines")
|
60
60
|
end
|
61
61
|
|
62
|
+
# Shows information about the merge request dependencies that must be resolved before merging.
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# Gitlab.merge_request_dependencies(5, 36)
|
66
|
+
#
|
67
|
+
# @param [Integer, String] project The ID or name of a project.
|
68
|
+
# @param [Integer] id The ID of a merge request.
|
69
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
70
|
+
def merge_request_dependencies(project, id)
|
71
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/blocks")
|
72
|
+
end
|
73
|
+
|
62
74
|
# Create a new pipeline for a merge request.
|
63
75
|
# A pipeline created via this endpoint doesnt run a regular branch/tag pipeline.
|
64
76
|
# It requires .gitlab-ci.yml to be configured with only: [merge_requests] to create jobs.
|
@@ -223,9 +235,11 @@ class Gitlab::Client
|
|
223
235
|
# Gitlab.merge_request_discussions('gitlab', 1)
|
224
236
|
# @param [Integer, String] project The ID or name of a project.
|
225
237
|
# @param [Integer] id The ID of a merge request.
|
238
|
+
# @option options [Integer] :page The page number.
|
239
|
+
# @option options [Integer] :per_page The number of results per page.
|
226
240
|
# @return [Gitlab::ObjectifiedHash] List of the merge request discussions.
|
227
|
-
def merge_request_discussions(project, merge_request_id)
|
228
|
-
get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions")
|
241
|
+
def merge_request_discussions(project, merge_request_id, options = {})
|
242
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", query: options)
|
229
243
|
end
|
230
244
|
|
231
245
|
# Get single merge request discussion
|
@@ -30,6 +30,18 @@ class Gitlab::Client
|
|
30
30
|
get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
|
31
31
|
end
|
32
32
|
|
33
|
+
# Get all pipelines triggered by a pipeline schedule
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# Gitlab.pipelines_by_pipeline_schedule(5, 3)
|
37
|
+
#
|
38
|
+
# @param [Integer, String] project The ID or name of a project.
|
39
|
+
# @param [Integer] id The ID of the pipeline schedule.
|
40
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
41
|
+
def pipelines_by_pipeline_schedule(project, id)
|
42
|
+
get("/projects/#{url_encode project}/pipeline_schedules/#{id}/pipelines")
|
43
|
+
end
|
44
|
+
|
33
45
|
# Create a pipeline schedule.
|
34
46
|
#
|
35
47
|
# @example
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Gitlab::Client
|
4
4
|
# Defines methods related to projects.
|
5
5
|
# @see https://docs.gitlab.com/ce/api/projects.html
|
6
|
-
module Projects
|
6
|
+
module Projects # rubocop:disable Metrics/ModuleLength
|
7
7
|
# Gets a list of projects owned by the authenticated user.
|
8
8
|
#
|
9
9
|
# @example
|
@@ -704,5 +704,85 @@ class Gitlab::Client
|
|
704
704
|
def project_deploy_tokens(project, options = {})
|
705
705
|
get("/projects/#{url_encode project}/deploy_tokens", query: options)
|
706
706
|
end
|
707
|
+
|
708
|
+
# Get languages used with percentage value
|
709
|
+
#
|
710
|
+
# @example
|
711
|
+
# Gitlab.project_languages(42)
|
712
|
+
#
|
713
|
+
# @param [Integer, String] id The ID or path of a project.
|
714
|
+
# @return [Gitlab::ObjectifiedHash]
|
715
|
+
def project_languages(project)
|
716
|
+
get("/projects/#{url_encode project}/languages")
|
717
|
+
end
|
718
|
+
|
719
|
+
# List all project access tokens.
|
720
|
+
#
|
721
|
+
# @example
|
722
|
+
# Gitlab.project_access_tokens(42)
|
723
|
+
#
|
724
|
+
# @param [Integer, String] project The ID or path of a project.
|
725
|
+
# @option options [String] :state Limit by active/inactive state. Optional.
|
726
|
+
#
|
727
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
728
|
+
def project_access_tokens(project, options = {})
|
729
|
+
get("/projects/#{url_encode project}/access_tokens", query: options)
|
730
|
+
end
|
731
|
+
|
732
|
+
# Get a specific project access token.
|
733
|
+
#
|
734
|
+
# @example
|
735
|
+
# Gitlab.project_access_token(42, 1234)
|
736
|
+
#
|
737
|
+
# @param [Integer, String] project The ID or path of a project.
|
738
|
+
# @param [Integer] token_id The ID of the project access token.
|
739
|
+
#
|
740
|
+
# @return [Gitlab::ObjectifiedHash] Information about the specified project access token.
|
741
|
+
def project_access_token(project, token_id)
|
742
|
+
get("/projects/#{url_encode project}/access_tokens/#{token_id}")
|
743
|
+
end
|
744
|
+
|
745
|
+
# Creates a new project access token.
|
746
|
+
#
|
747
|
+
# @example
|
748
|
+
# Gitlab.create_project_access_token(42, 'My Token', ['api'], '2024-12-12', access_level: 40)
|
749
|
+
#
|
750
|
+
# @param [Integer, String] project The ID or path of a project.
|
751
|
+
# @param [String] name The name of the project access token.
|
752
|
+
# @param [Array] scopes List of scopes of the project access token.
|
753
|
+
# @param [String] expires_at A date string in the format YYYY-MM-DD.
|
754
|
+
# @option options [Integer] :access_level Access level. Optional. Defaults to 40.
|
755
|
+
#
|
756
|
+
# @return [Gitlab::ObjectifiedHash] Information about the created project access token.
|
757
|
+
def create_project_access_token(project, name, scopes, expires_at, options = {})
|
758
|
+
post("/projects/#{url_encode project}/access_tokens", body: { name: name, scopes: scopes, expires_at: expires_at }.merge(options))
|
759
|
+
end
|
760
|
+
|
761
|
+
# Rotate a project access token.
|
762
|
+
#
|
763
|
+
# @example
|
764
|
+
# Gitlab.rotate_project_access_token(42, 1234)
|
765
|
+
#
|
766
|
+
# @param [Integer, String] project The ID or path of a project.
|
767
|
+
# @param [Integer] token_id The ID of the project access token.
|
768
|
+
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
769
|
+
#
|
770
|
+
# @return [Gitlab::ObjectifiedHash] Information about the specified project access token.
|
771
|
+
def rotate_project_access_token(project, token_id, options = {})
|
772
|
+
post("/projects/#{url_encode project}/access_tokens/#{token_id}/rotate", query: options)
|
773
|
+
end
|
774
|
+
|
775
|
+
# Revoke a project access token.
|
776
|
+
#
|
777
|
+
# @example
|
778
|
+
# Gitlab.revoke_project_access_token(42, 1234)
|
779
|
+
#
|
780
|
+
# @param [Integer, String] project The ID or path of a project.
|
781
|
+
# @param [Integer] token_id The ID of the project access token.
|
782
|
+
#
|
783
|
+
# @return [Gitlab::ObjectifiedHash]
|
784
|
+
def revoke_project_access_token(project, token_id)
|
785
|
+
delete("/projects/#{url_encode project}/access_tokens/#{token_id}")
|
786
|
+
end
|
707
787
|
end
|
708
788
|
end
|
data/lib/gitlab/client.rb
CHANGED
@@ -77,7 +77,7 @@ module Gitlab
|
|
77
77
|
# @return [String]
|
78
78
|
def inspect
|
79
79
|
inspected = super
|
80
|
-
inspected
|
80
|
+
inspected = redact_private_token(inspected, @private_token) if @private_token
|
81
81
|
inspected
|
82
82
|
end
|
83
83
|
|
@@ -91,7 +91,14 @@ module Gitlab
|
|
91
91
|
|
92
92
|
private
|
93
93
|
|
94
|
+
def redact_private_token(inspected, private_token)
|
95
|
+
redacted = only_show_last_four_chars(private_token)
|
96
|
+
inspected.sub %(@private_token="#{private_token}"), %(@private_token="#{redacted}")
|
97
|
+
end
|
98
|
+
|
94
99
|
def only_show_last_four_chars(token)
|
100
|
+
return '****' if token.size <= 4
|
101
|
+
|
95
102
|
"#{'*' * (token.size - 4)}#{token[-4..]}"
|
96
103
|
end
|
97
104
|
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].freeze
|
8
|
+
VALID_OPTIONS_KEYS = %i[endpoint private_token user_agent sudo httparty pat_prefix].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}"
|
@@ -37,6 +37,7 @@ module Gitlab
|
|
37
37
|
def reset
|
38
38
|
self.endpoint = ENV['GITLAB_API_ENDPOINT'] || ENV['CI_API_V4_URL']
|
39
39
|
self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['GITLAB_API_AUTH_TOKEN']
|
40
|
+
self.pat_prefix = nil
|
40
41
|
self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS'])
|
41
42
|
self.sudo = nil
|
42
43
|
self.user_agent = DEFAULT_USER_AGENT
|
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
|
15
|
+
attr_accessor :private_token, :endpoint, :pat_prefix
|
16
16
|
|
17
17
|
# Converts the response body to an ObjectifiedHash.
|
18
18
|
def self.parse(body)
|
@@ -93,10 +93,19 @@ module Gitlab
|
|
93
93
|
def authorization_header
|
94
94
|
raise Error::MissingCredentials, 'Please provide a private_token or auth_token for user' unless private_token
|
95
95
|
|
96
|
-
|
96
|
+
# The Personal Access Token prefix can be at most 20 characters, and the
|
97
|
+
# generated part is of length 20 characters. Personal Access Tokens, thus
|
98
|
+
# can have a maximum size of 40 characters. GitLab uses
|
99
|
+
# `Doorkeeper::OAuth::Helpers::UniqueToken.generate` for generating
|
100
|
+
# OAuth2 tokens, and specified `hex` as token generator method. Thus, the
|
101
|
+
# OAuth2 tokens are of length more than 64. If the token length is below
|
102
|
+
# that, it is probably a Personal Access Token or CI_JOB_TOKEN.
|
103
|
+
if private_token.size >= 64
|
104
|
+
{ 'Authorization' => "Bearer #{private_token}" }
|
105
|
+
elsif private_token.start_with?(pat_prefix.to_s)
|
97
106
|
{ 'PRIVATE-TOKEN' => private_token }
|
98
107
|
else
|
99
|
-
{ '
|
108
|
+
{ 'JOB-TOKEN' => private_token }
|
100
109
|
end
|
101
110
|
end
|
102
111
|
|
data/lib/gitlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nihad Abbasov
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: base64
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.2.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.2.0
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: httparty
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
214
|
- !ruby/object:Gem::Version
|
201
215
|
version: '0'
|
202
216
|
requirements: []
|
203
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.5.16
|
204
218
|
signing_key:
|
205
219
|
specification_version: 4
|
206
220
|
summary: A Ruby wrapper and CLI for the GitLab API
|