gitlab 4.15.0 → 4.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/gitlab.rb +2 -1
- data/lib/gitlab/client.rb +1 -0
- data/lib/gitlab/client/merge_request_approvals.rb +12 -0
- data/lib/gitlab/client/merge_requests.rb +18 -3
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/help.rb +3 -3
- data/lib/gitlab/objectified_hash.rb +16 -7
- data/lib/gitlab/page_links.rb +1 -1
- data/lib/gitlab/paginated_response.rb +14 -31
- data/lib/gitlab/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d417a687fa4ad735c02fa7225f71be9401735c5c0fcace3ba199c3c79850e53a
|
4
|
+
data.tar.gz: 859603a7a30353d20ad041dcb0bb557931c576906fd495830f922bd1270431b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34db8a032fa734b07582d0ce1a9be357137458ed6819dc50920af6cfad734629ece8b042890b0032f77cd259c3c63ae2b06c48e8d7ebb4af8baae49b17af9e45
|
7
|
+
data.tar.gz: 2d396786aa1cf2f03a72eeea6662275caeaedf489d3da42c7a9528e82c1ce5464cc8a8b9c722e3dacdaa121c9fd547e2cd1c34136584b627aab6460ab0a99b73
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Gitlab
|
2
2
|
|
3
3
|
[![Build Status](https://img.shields.io/github/workflow/status/NARKOZ/gitlab/CI/master)](https://github.com/NARKOZ/gitlab/actions?query=workflow%3ARuby)
|
4
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/2e310b334b1b5db4a7e1/maintainability)](https://codeclimate.com/github/NARKOZ/gitlab)
|
5
4
|
[![Inline docs](https://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab)
|
6
5
|
[![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab)
|
7
6
|
[![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
|
data/lib/gitlab.rb
CHANGED
@@ -42,7 +42,8 @@ module Gitlab
|
|
42
42
|
#
|
43
43
|
# @return [Array<Symbol>]
|
44
44
|
def self.actions
|
45
|
-
hidden =
|
45
|
+
hidden =
|
46
|
+
/endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate\z|request_defaults|httparty/
|
46
47
|
(Gitlab::Client.instance_methods - Object.methods).reject { |e| e[hidden] }
|
47
48
|
end
|
48
49
|
end
|
data/lib/gitlab/client.rb
CHANGED
@@ -165,5 +165,17 @@ class Gitlab::Client
|
|
165
165
|
def unapprove_merge_request(project, merge_request, options = {})
|
166
166
|
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove", body: options)
|
167
167
|
end
|
168
|
+
|
169
|
+
# Get the approval state of merge requests
|
170
|
+
#
|
171
|
+
# @example
|
172
|
+
# Gitlab.merge_request_approval_state(5, 36)
|
173
|
+
#
|
174
|
+
# @param [Integer, String] project The ID or name of a project.
|
175
|
+
# @param [Integer] id The ID of a merge request.
|
176
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
177
|
+
def merge_request_approval_state(project, id)
|
178
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/approval_state")
|
179
|
+
end
|
168
180
|
end
|
169
181
|
end
|
@@ -35,12 +35,16 @@ class Gitlab::Client
|
|
35
35
|
#
|
36
36
|
# @example
|
37
37
|
# Gitlab.merge_request(5, 36)
|
38
|
+
# Gitlab.merge_request(5, 36, { include_diverged_commits_count: true })
|
38
39
|
#
|
39
40
|
# @param [Integer, String] project The ID or name of a project.
|
40
41
|
# @param [Integer] id The ID of a merge request.
|
42
|
+
# @option options [Boolean] :render_html If true response includes rendered HTML for title and description.
|
43
|
+
# @option options [Boolean] :include_diverged_commits_count If true response includes the commits behind the target branch.
|
44
|
+
# @option options [Boolean] :include_rebase_in_progress If true response includes whether a rebase operation is in progress.
|
41
45
|
# @return <Gitlab::ObjectifiedHash]
|
42
|
-
def merge_request(project, id)
|
43
|
-
get("/projects/#{url_encode project}/merge_requests/#{id}")
|
46
|
+
def merge_request(project, id, options = {})
|
47
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}", query: options)
|
44
48
|
end
|
45
49
|
|
46
50
|
# Gets a list of merge request pipelines.
|
@@ -81,8 +85,14 @@ class Gitlab::Client
|
|
81
85
|
# @option options [String] :source_branch (required) The source branch name.
|
82
86
|
# @option options [String] :target_branch (required) The target branch name.
|
83
87
|
# @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
|
88
|
+
# @option options [Array<Integer>] :assignee_ids (optional) The ID of the user(s) to assign the MR to. Set to 0 or provide an empty value to unassign all assignees.
|
89
|
+
# @option options [String] :description (optional) Description of MR. Limited to 1,048,576 characters.
|
84
90
|
# @option options [Integer] :target_project_id (optional) The target project ID.
|
85
91
|
# @option options [String] :labels (optional) Labels as a comma-separated list.
|
92
|
+
# @option options [Integer] :milestone_id (optional) The global ID of a milestone
|
93
|
+
# @option options [Boolean] :remove_source_branch (optional) Flag indicating if a merge request should remove the source branch when merging
|
94
|
+
# @option options [Boolean] :allow_collaboration (optional) Allow commits from members who can merge to the target branch
|
95
|
+
# @option options [Boolean] :squash (optional) Squash commits into a single commit when merging
|
86
96
|
# @return [Gitlab::ObjectifiedHash] Information about created merge request.
|
87
97
|
def create_merge_request(project, title, options = {})
|
88
98
|
body = { title: title }.merge(options)
|
@@ -115,7 +125,12 @@ class Gitlab::Client
|
|
115
125
|
# @param [Integer, String] project The ID or name of a project.
|
116
126
|
# @param [Integer] id The ID of a merge request.
|
117
127
|
# @param [Hash] options A customizable set of options.
|
118
|
-
# @option options [String] :merge_commit_message Custom merge commit message
|
128
|
+
# @option options [String] :merge_commit_message(optional) Custom merge commit message
|
129
|
+
# @option options [String] :squash_commit_message(optional) Custom squash commit message
|
130
|
+
# @option options [Boolean] :squash(optional) if true the commits will be squashed into a single commit on merge
|
131
|
+
# @option options [Boolean] :should_remove_source_branch(optional) if true removes the source branch
|
132
|
+
# @option options [Boolean] :merge_when_pipeline_succeeds(optional) if true the MR is merged when the pipeline succeeds
|
133
|
+
# @option options [String] :sha(optional) if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail
|
119
134
|
# @return [Gitlab::ObjectifiedHash] Information about updated merge request.
|
120
135
|
def accept_merge_request(project, id, options = {})
|
121
136
|
put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to user snippets.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/snippets.html
|
6
|
+
module UserSnippets
|
7
|
+
# Get a list of the snippets of the current user.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.user_snippets
|
11
|
+
#
|
12
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of snippets of current user
|
13
|
+
def user_snippets
|
14
|
+
get('/snippets')
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a single snippet.
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# Gitlab.user_snippet(1)
|
21
|
+
#
|
22
|
+
# @param [Integer] id ID of snippet to retrieve.
|
23
|
+
# @return [Gitlab::ObjectifiedHash] Information about the user snippet
|
24
|
+
def user_snippet(id)
|
25
|
+
get("/snippets/#{id}")
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get raw contents of a single snippet.
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# Gitlab.user_snippet_raw(1)
|
32
|
+
#
|
33
|
+
# @param [Integer] id ID of snippet to retrieve.
|
34
|
+
# @return [String] User snippet text
|
35
|
+
def user_snippet_raw(id)
|
36
|
+
get("/snippets/#{id}/raw",
|
37
|
+
format: nil,
|
38
|
+
headers: { Accept: 'text/plain' },
|
39
|
+
parser: ::Gitlab::Request::Parser)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a new snippet.
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# Gitlab.create_user_snippet({ title: 'REST', file_name: 'api.rb', content: 'some code', description: 'Hello World snippet', visibility: 'public'})
|
46
|
+
#
|
47
|
+
# @param [Hash] options A customizable set of options.
|
48
|
+
# @option options [String] :title (required) Title of a snippet.
|
49
|
+
# @option options [String] :file_name (required) Name of a snippet file.
|
50
|
+
# @option options [String] :content (required) Content of a snippet.
|
51
|
+
# @option options [String] :description (optional) Description of a snippet.
|
52
|
+
# @option options [String] :visibility (optional) visibility of a snippet.
|
53
|
+
# @return [Gitlab::ObjectifiedHash] Information about created snippet.
|
54
|
+
def create_user_snippet(options = {})
|
55
|
+
post('/snippets', body: options)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Update an existing snippet.
|
59
|
+
#
|
60
|
+
# @example
|
61
|
+
# Gitlab.edit_user_snippet(34, { file_name: 'README.txt' })
|
62
|
+
# Gitlab.edit_user_snippet(34, { file_name: 'README.txt', title: 'New title' })
|
63
|
+
#
|
64
|
+
# @param [Integer] id ID of snippet to update.
|
65
|
+
# @param [Hash] options A customizable set of options.
|
66
|
+
# @option options [String] :title (optional) Title of a snippet.
|
67
|
+
# @option options [String] :file_name (optional) Name of a snippet file.
|
68
|
+
# @option options [String] :content (optional) Content of a snippet.
|
69
|
+
# @option options [String] :description (optional) Description of a snippet.
|
70
|
+
# @option options [String] :visibility (optional) visibility of a snippet.
|
71
|
+
# @return [Gitlab::ObjectifiedHash] Information about updated snippet.
|
72
|
+
def edit_user_snippet(id, options = {})
|
73
|
+
put("/snippets/#{id}", body: options)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Delete an existing snippet.
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# Gitlab.delete_user_snippet(14)
|
80
|
+
#
|
81
|
+
# @param [Integer] id ID of snippet to delete.
|
82
|
+
# @return [void] This API call returns an empty response body.
|
83
|
+
def delete_user_snippet(id)
|
84
|
+
delete("/snippets/#{id}")
|
85
|
+
end
|
86
|
+
|
87
|
+
# List all public snippets.
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# Gitlab.public_snippets
|
91
|
+
# Gitlab.public_snippets(per_page: 2, page: 1)
|
92
|
+
#
|
93
|
+
# @param [Hash] options A customizable set of options.
|
94
|
+
# @option options [String] :per_page (optional) Number of snippets to return per page.
|
95
|
+
# @option options [String] :page (optional) Page to retrieve.
|
96
|
+
#
|
97
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all public snippets
|
98
|
+
def public_snippets(options = {})
|
99
|
+
get('/snippets/public', query: options)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Get user agent details for a snippet.
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# Gitlab.snippet_user_agent_details(1)
|
106
|
+
#
|
107
|
+
# @param [Integer] id ID of snippet to delete.
|
108
|
+
#
|
109
|
+
# @return [Array<Gitlab::ObjectifiedHash>] Details of the user agent
|
110
|
+
def snippet_user_agent_details(id)
|
111
|
+
get("/snippets/#{id}/user_agent_detail")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/lib/gitlab/help.rb
CHANGED
@@ -82,13 +82,13 @@ module Gitlab::Help
|
|
82
82
|
def change_help_output!(cmd, output_str)
|
83
83
|
output_str = +output_str
|
84
84
|
output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
|
85
|
-
output_str.gsub!(
|
85
|
+
output_str.gsub!(/,\s*/, ' ')
|
86
86
|
|
87
87
|
# Ensure @option descriptions are on a single line
|
88
88
|
output_str.gsub!(/\n\[/, " \[")
|
89
89
|
output_str.gsub!(/\s(@)/, "\n@")
|
90
|
-
output_str.gsub!(/(\])\n(
|
91
|
-
output_str.gsub!(/(
|
90
|
+
output_str.gsub!(/(\])\n(:)/, '\1 \2')
|
91
|
+
output_str.gsub!(/(:.*)(\n)(.*\.)/, '\1 \3')
|
92
92
|
output_str.gsub!(/\{(.+)\}/, '"{\1}"')
|
93
93
|
end
|
94
94
|
end
|
@@ -7,29 +7,38 @@ module Gitlab
|
|
7
7
|
def initialize(hash)
|
8
8
|
@hash = hash
|
9
9
|
@data = hash.each_with_object({}) do |(key, value), data|
|
10
|
-
value =
|
10
|
+
value = self.class.new(value) if value.is_a? Hash
|
11
|
+
value = value.map { |v| v.is_a?(Hash) ? self.class.new(v) : v } if value.is_a? Array
|
11
12
|
data[key.to_s] = value
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
# @return [Hash] The original hash.
|
16
17
|
def to_hash
|
17
|
-
|
18
|
+
hash
|
18
19
|
end
|
19
20
|
alias to_h to_hash
|
20
21
|
|
21
22
|
# @return [String] Formatted string with the class name, object id and original hash.
|
22
23
|
def inspect
|
23
|
-
"#<#{self.class}:#{object_id} {hash: #{
|
24
|
+
"#<#{self.class}:#{object_id} {hash: #{hash.inspect}}"
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def [](key)
|
28
|
+
data[key]
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :hash, :data
|
34
|
+
|
35
|
+
# Respond to messages for which `self.data` has a key
|
36
|
+
def method_missing(method_name, *args, &block)
|
37
|
+
data.key?(method_name.to_s) ? data[method_name.to_s] : super
|
29
38
|
end
|
30
39
|
|
31
40
|
def respond_to_missing?(method_name, include_private = false)
|
32
|
-
|
41
|
+
hash.keys.map(&:to_sym).include?(method_name.to_sym) || super
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
data/lib/gitlab/page_links.rb
CHANGED
@@ -42,37 +42,20 @@ module Gitlab
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
def paginate_with_limit(limit)
|
60
|
-
response = block_given? ? nil : []
|
61
|
-
count = 0
|
62
|
-
each_page do |page|
|
63
|
-
if block_given?
|
64
|
-
page.each do |item|
|
65
|
-
yield item
|
66
|
-
count += 1
|
67
|
-
break if count >= limit
|
68
|
-
end
|
69
|
-
else
|
70
|
-
response += page[0, limit - count]
|
71
|
-
count = response.length
|
72
|
-
end
|
73
|
-
break if count >= limit
|
74
|
-
end
|
75
|
-
response
|
45
|
+
def lazy_paginate
|
46
|
+
to_enum(:each_page).lazy.flat_map(&:to_ary)
|
47
|
+
end
|
48
|
+
|
49
|
+
def auto_paginate(&block)
|
50
|
+
return lazy_paginate.to_a unless block_given?
|
51
|
+
|
52
|
+
lazy_paginate.each(&block)
|
53
|
+
end
|
54
|
+
|
55
|
+
def paginate_with_limit(limit, &block)
|
56
|
+
return lazy_paginate.take(limit).to_a unless block_given?
|
57
|
+
|
58
|
+
lazy_paginate.take(limit).each(&block)
|
76
59
|
end
|
77
60
|
|
78
61
|
def last_page?
|
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: 4.
|
4
|
+
version: 4.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nihad Abbasov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/gitlab/client/tags.rb
|
167
167
|
- lib/gitlab/client/templates.rb
|
168
168
|
- lib/gitlab/client/todos.rb
|
169
|
+
- lib/gitlab/client/user_snippets.rb
|
169
170
|
- lib/gitlab/client/users.rb
|
170
171
|
- lib/gitlab/client/versions.rb
|
171
172
|
- lib/gitlab/client/wikis.rb
|