gitlab 4.16.1 → 4.18.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gitlab/help.rb CHANGED
@@ -45,14 +45,13 @@ module Gitlab::Help
45
45
  #
46
46
  # @return [Hash<Array>]
47
47
  def help_map
48
- @help_map ||= begin
48
+ @help_map ||=
49
49
  actions.each_with_object({}) do |action, hsh|
50
50
  key = client.method(action)
51
51
  .owner.to_s.gsub(/Gitlab::(?:Client::)?/, '')
52
52
  hsh[key] ||= []
53
53
  hsh[key] << action.to_s
54
54
  end
55
- end
56
55
  end
57
56
 
58
57
  # Table with available commands.
@@ -74,22 +73,22 @@ module Gitlab::Help
74
73
  # Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd)
75
74
  def namespace(cmd)
76
75
  method_owners.select { |method| method[:name] == cmd }
77
- .map { |method| method[:owner] + '.' + method[:name] }
76
+ .map { |method| "#{method[:owner]}.#{method[:name]}" }
78
77
  .shift
79
78
  end
80
79
 
81
80
  # Massage output from 'ri'.
82
81
  def change_help_output!(cmd, output_str)
83
82
  output_str = +output_str
84
- output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
85
- output_str.gsub!(/,\s*/, ' ')
83
+ output_str.gsub!(/#{cmd}(\(.*?\))/m, "#{cmd}\\1")
84
+ output_str.gsub!(/,\s*/, ', ')
86
85
 
87
86
  # Ensure @option descriptions are on a single line
88
87
  output_str.gsub!(/\n\[/, " \[")
89
88
  output_str.gsub!(/\s(@)/, "\n@")
90
- output_str.gsub!(/(\])\n(:)/, '\1 \2')
91
- output_str.gsub!(/(:.*)(\n)(.*\.)/, '\1 \3')
92
- output_str.gsub!(/\{(.+)\}/, '"{\1}"')
89
+ output_str.gsub!(/(\])\n(:)/, '\\1 \\2')
90
+ output_str.gsub!(/(:.*)(\n)(.*\.)/, '\\1 \\3')
91
+ output_str.gsub!(/\{(.+)\}/, '"{\\1}"')
93
92
  end
94
93
  end
95
94
  end
@@ -47,13 +47,13 @@ module Gitlab
47
47
  end
48
48
 
49
49
  def auto_paginate(&block)
50
- return lazy_paginate.to_a unless block_given?
50
+ return lazy_paginate.to_a unless block
51
51
 
52
52
  lazy_paginate.each(&block)
53
53
  end
54
54
 
55
55
  def paginate_with_limit(limit, &block)
56
- return lazy_paginate.take(limit).to_a unless block_given?
56
+ return lazy_paginate.take(limit).to_a unless block
57
57
 
58
58
  lazy_paginate.take(limit).each(&block)
59
59
  end
@@ -8,6 +8,7 @@ module Gitlab
8
8
  class Request
9
9
  include HTTParty
10
10
  format :json
11
+ maintain_method_across_redirects true
11
12
  headers 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'
12
13
  parser(proc { |body, _| parse(body) })
13
14
 
@@ -25,8 +26,6 @@ module Gitlab
25
26
  true
26
27
  elsif !body
27
28
  false
28
- elsif body.nil?
29
- false
30
29
  else
31
30
  raise Error::Parsing, "Couldn't parse a response body"
32
31
  end
@@ -50,7 +49,18 @@ module Gitlab
50
49
  params[:headers].merge!(authorization_header)
51
50
  end
52
51
 
53
- validate self.class.send(method, @endpoint + path, params)
52
+ retries_left = params[:ratelimit_retries] || 3
53
+ begin
54
+ response = self.class.send(method, endpoint + path, params)
55
+ validate response
56
+ rescue Gitlab::Error::TooManyRequests => e
57
+ retries_left -= 1
58
+ raise e if retries_left.zero?
59
+
60
+ wait_time = response.headers['Retry-After'] || 2
61
+ sleep(wait_time.to_i)
62
+ retry
63
+ end
54
64
  end
55
65
  end
56
66
 
@@ -69,7 +79,7 @@ module Gitlab
69
79
  # Sets a base_uri and default_params for requests.
70
80
  # @raise [Error::MissingCredentials] if endpoint not set.
71
81
  def request_defaults(sudo = nil)
72
- raise Error::MissingCredentials, 'Please set an endpoint to API' unless @endpoint
82
+ raise Error::MissingCredentials, 'Please set an endpoint to API' unless endpoint
73
83
 
74
84
  self.class.default_params sudo: sudo
75
85
  self.class.default_params.delete(:sudo) if sudo.nil?
@@ -81,12 +91,12 @@ module Gitlab
81
91
  #
82
92
  # @raise [Error::MissingCredentials] if private_token and auth_token are not set.
83
93
  def authorization_header
84
- raise Error::MissingCredentials, 'Please provide a private_token or auth_token for user' unless @private_token
94
+ raise Error::MissingCredentials, 'Please provide a private_token or auth_token for user' unless private_token
85
95
 
86
- if @private_token.size < 21
87
- { 'PRIVATE-TOKEN' => @private_token }
96
+ if private_token.size < 21
97
+ { 'PRIVATE-TOKEN' => private_token }
88
98
  else
89
- { 'Authorization' => "Bearer #{@private_token}" }
99
+ { 'Authorization' => "Bearer #{private_token}" }
90
100
  end
91
101
  end
92
102
 
@@ -42,10 +42,10 @@ class Gitlab::Shell
42
42
  File.expand_path(@file_path)
43
43
  end
44
44
 
45
- def read_from_file
45
+ def read_from_file(&block)
46
46
  path = history_file_path
47
47
 
48
- File.foreach(path) { |line| yield(line) } if File.exist?(path)
48
+ File.foreach(path, &block) if File.exist?(path)
49
49
  rescue StandardError => e
50
50
  warn "History file not loaded: #{e.message}"
51
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gitlab
4
- VERSION = '4.16.1'
4
+ VERSION = '4.18.0'
5
5
  end
data/lib/gitlab.rb CHANGED
@@ -21,11 +21,18 @@ module Gitlab
21
21
  Gitlab::Client.new(options)
22
22
  end
23
23
 
24
- # Delegate to Gitlab::Client
25
- def self.method_missing(method, *args, &block)
26
- return super unless client.respond_to?(method)
27
-
28
- client.send(method, *args, &block)
24
+ if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new('3.0.0')
25
+ def self.method_missing(method, *args, **keywargs, &block)
26
+ return super unless client.respond_to?(method)
27
+
28
+ client.send(method, *args, **keywargs, &block)
29
+ end
30
+ else
31
+ def self.method_missing(method, *args, &block)
32
+ return super unless client.respond_to?(method)
33
+
34
+ client.send(method, *args, &block)
35
+ end
29
36
  end
30
37
 
31
38
  # Delegate to Gitlab::Client
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.16.1
4
+ version: 4.18.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-07-12 00:00:00.000000000 Z
12
+ date: 2021-12-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -17,27 +17,18 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0.14'
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.14.0
20
+ version: '0.18'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
27
24
  requirements:
28
25
  - - "~>"
29
26
  - !ruby/object:Gem::Version
30
- version: '0.14'
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.14.0
27
+ version: '0.18'
34
28
  - !ruby/object:Gem::Dependency
35
29
  name: terminal-table
36
30
  requirement: !ruby/object:Gem::Requirement
37
31
  requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.5'
41
32
  - - ">="
42
33
  - !ruby/object:Gem::Version
43
34
  version: 1.5.1
@@ -45,9 +36,6 @@ dependencies:
45
36
  prerelease: false
46
37
  version_requirements: !ruby/object:Gem::Requirement
47
38
  requirements:
48
- - - "~>"
49
- - !ruby/object:Gem::Version
50
- version: '1.5'
51
39
  - - ">="
52
40
  - !ruby/object:Gem::Version
53
41
  version: 1.5.1
@@ -128,6 +116,7 @@ files:
128
116
  - lib/gitlab/client/epics.rb
129
117
  - lib/gitlab/client/events.rb
130
118
  - lib/gitlab/client/features.rb
119
+ - lib/gitlab/client/group_badges.rb
131
120
  - lib/gitlab/client/group_boards.rb
132
121
  - lib/gitlab/client/group_labels.rb
133
122
  - lib/gitlab/client/group_milestones.rb
@@ -153,10 +142,12 @@ files:
153
142
  - lib/gitlab/client/project_releases.rb
154
143
  - lib/gitlab/client/projects.rb
155
144
  - lib/gitlab/client/protected_tags.rb
145
+ - lib/gitlab/client/remote_mirrors.rb
156
146
  - lib/gitlab/client/repositories.rb
157
147
  - lib/gitlab/client/repository_files.rb
158
148
  - lib/gitlab/client/repository_submodules.rb
159
149
  - lib/gitlab/client/resource_label_events.rb
150
+ - lib/gitlab/client/resource_state_events.rb
160
151
  - lib/gitlab/client/runners.rb
161
152
  - lib/gitlab/client/search.rb
162
153
  - lib/gitlab/client/services.rb
@@ -200,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
191
  - !ruby/object:Gem::Version
201
192
  version: '0'
202
193
  requirements: []
203
- rubygems_version: 3.1.2
194
+ rubygems_version: 3.1.6
204
195
  signing_key:
205
196
  specification_version: 4
206
197
  summary: A Ruby wrapper and CLI for the GitLab API