gitlab 4.8.0 → 4.13.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -7
  3. data/lib/gitlab/cli.rb +0 -3
  4. data/lib/gitlab/cli_helpers.rb +11 -10
  5. data/lib/gitlab/client.rb +15 -0
  6. data/lib/gitlab/client/application_settings.rb +172 -0
  7. data/lib/gitlab/client/avatar.rb +21 -0
  8. data/lib/gitlab/client/boards.rb +56 -0
  9. data/lib/gitlab/client/build_variables.rb +14 -10
  10. data/lib/gitlab/client/commits.rb +18 -2
  11. data/lib/gitlab/client/container_registry.rb +85 -0
  12. data/lib/gitlab/client/epics.rb +73 -0
  13. data/lib/gitlab/client/features.rb +48 -0
  14. data/lib/gitlab/client/group_boards.rb +141 -0
  15. data/lib/gitlab/client/group_labels.rb +88 -0
  16. data/lib/gitlab/client/groups.rb +66 -2
  17. data/lib/gitlab/client/issue_links.rb +48 -0
  18. data/lib/gitlab/client/labels.rb +1 -1
  19. data/lib/gitlab/client/lint.rb +19 -0
  20. data/lib/gitlab/client/markdown.rb +23 -0
  21. data/lib/gitlab/client/merge_request_approvals.rb +9 -8
  22. data/lib/gitlab/client/merge_requests.rb +12 -0
  23. data/lib/gitlab/client/notes.rb +1 -1
  24. data/lib/gitlab/client/pipelines.rb +12 -0
  25. data/lib/gitlab/client/project_clusters.rb +83 -0
  26. data/lib/gitlab/client/project_release_links.rb +76 -0
  27. data/lib/gitlab/client/project_releases.rb +79 -0
  28. data/lib/gitlab/client/projects.rb +27 -6
  29. data/lib/gitlab/client/repositories.rb +5 -3
  30. data/lib/gitlab/client/repository_files.rb +16 -0
  31. data/lib/gitlab/client/resource_label_events.rb +82 -0
  32. data/lib/gitlab/client/runners.rb +49 -2
  33. data/lib/gitlab/client/search.rb +66 -0
  34. data/lib/gitlab/client/users.rb +7 -9
  35. data/lib/gitlab/configuration.rb +1 -1
  36. data/lib/gitlab/error.rb +46 -1
  37. data/lib/gitlab/paginated_response.rb +19 -0
  38. data/lib/gitlab/request.rb +15 -25
  39. data/lib/gitlab/shell_history.rb +4 -8
  40. data/lib/gitlab/version.rb +1 -1
  41. metadata +33 -15
  42. data/.github/stale.yml +0 -18
  43. data/.gitignore +0 -22
  44. data/.rubocop_todo.yml +0 -46
  45. data/CONTRIBUTING.md +0 -195
  46. data/Gemfile +0 -6
  47. data/Rakefile +0 -15
  48. data/bin/console +0 -11
  49. data/bin/setup +0 -6
  50. data/gitlab.gemspec +0 -36
@@ -42,7 +42,12 @@ module Gitlab
42
42
  %w[get post put delete].each do |method|
43
43
  define_method method do |path, options = {}|
44
44
  httparty_config(options)
45
- authorization_header(options)
45
+
46
+ unless options[:unauthenticated]
47
+ options[:headers] ||= {}
48
+ options[:headers].merge!(authorization_header)
49
+ end
50
+
46
51
  validate self.class.send(method, @endpoint + path, options)
47
52
  end
48
53
  end
@@ -50,19 +55,7 @@ module Gitlab
50
55
  # Checks the response code for common errors.
51
56
  # Returns parsed response for successful requests.
52
57
  def validate(response)
53
- error_klass = case response.code
54
- when 400 then Error::BadRequest
55
- when 401 then Error::Unauthorized
56
- when 403 then Error::Forbidden
57
- when 404 then Error::NotFound
58
- when 405 then Error::MethodNotAllowed
59
- when 409 then Error::Conflict
60
- when 422 then Error::Unprocessable
61
- when 500 then Error::InternalServerError
62
- when 502 then Error::BadGateway
63
- when 503 then Error::ServiceUnavailable
64
- end
65
-
58
+ error_klass = Error::STATUS_MAPPINGS[response.code]
66
59
  raise error_klass, response if error_klass
67
60
 
68
61
  parsed = response.parsed_response
@@ -74,28 +67,25 @@ module Gitlab
74
67
  # Sets a base_uri and default_params for requests.
75
68
  # @raise [Error::MissingCredentials] if endpoint not set.
76
69
  def request_defaults(sudo = nil)
77
- self.class.default_params sudo: sudo
78
70
  raise Error::MissingCredentials, 'Please set an endpoint to API' unless @endpoint
79
71
 
72
+ self.class.default_params sudo: sudo
80
73
  self.class.default_params.delete(:sudo) if sudo.nil?
81
74
  end
82
75
 
83
76
  private
84
77
 
85
- # Sets a PRIVATE-TOKEN or Authorization header for requests.
78
+ # Returns an Authorization header hash
86
79
  #
87
- # @param [Hash] options A customizable set of options.
88
- # @option options [Boolean] :unauthenticated true if the API call does not require user authentication.
89
80
  # @raise [Error::MissingCredentials] if private_token and auth_token are not set.
90
- def authorization_header(options)
91
- return if options[:unauthenticated]
81
+ def authorization_header
92
82
  raise Error::MissingCredentials, 'Please provide a private_token or auth_token for user' unless @private_token
93
83
 
94
- options[:headers] = if @private_token.size < 21
95
- { 'PRIVATE-TOKEN' => @private_token }
96
- else
97
- { 'Authorization' => "Bearer #{@private_token}" }
98
- end
84
+ if @private_token.size < 21
85
+ { 'PRIVATE-TOKEN' => @private_token }
86
+ else
87
+ { 'Authorization' => "Bearer #{@private_token}" }
88
+ end
99
89
  end
100
90
 
101
91
  # Set HTTParty configuration
@@ -30,12 +30,8 @@ class Gitlab::Shell
30
30
  private
31
31
 
32
32
  def history_file
33
- if defined?(@history_file)
34
- @history_file
35
- else
36
- @history_file = File.open(history_file_path, 'w', 0o600).tap do |file|
37
- file.sync = true
38
- end
33
+ @history_file ||= File.open(history_file_path, 'w', 0o600).tap do |file|
34
+ file.sync = true
39
35
  end
40
36
  rescue Errno::EACCES
41
37
  warn 'History not saved; unable to open your history file for writing.'
@@ -50,8 +46,8 @@ class Gitlab::Shell
50
46
  path = history_file_path
51
47
 
52
48
  File.foreach(path) { |line| yield(line) } if File.exist?(path)
53
- rescue StandardError => error
54
- warn "History file not loaded: #{error.message}"
49
+ rescue StandardError => e
50
+ warn "History file not loaded: #{e.message}"
55
51
  end
56
52
 
57
53
  def max_lines
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gitlab
4
- VERSION = '4.8.0'
4
+ VERSION = '4.13.0'
5
5
  end
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.8.0
4
+ version: 4.13.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: 2018-12-27 00:00:00.000000000 Z
12
+ date: 2019-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -18,6 +18,9 @@ dependencies:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.14.0
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '0.14'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,10 +28,16 @@ dependencies:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: 0.14.0
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: terminal-table
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
32
41
  - - ">="
33
42
  - !ruby/object:Gem::Version
34
43
  version: 1.5.1
@@ -36,6 +45,9 @@ dependencies:
36
45
  prerelease: false
37
46
  version_requirements: !ruby/object:Gem::Requirement
38
47
  requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '1.5'
39
51
  - - ">="
40
52
  - !ruby/object:Gem::Version
41
53
  version: 1.5.1
@@ -111,32 +123,25 @@ dependencies:
111
123
  version: '0'
112
124
  description: Ruby client and CLI for GitLab API
113
125
  email:
114
- - mail@narkoz.me
126
+ - nihad@42na.in
115
127
  - asedge@gmail.com
116
128
  executables:
117
129
  - gitlab
118
130
  extensions: []
119
131
  extra_rdoc_files: []
120
132
  files:
121
- - ".github/stale.yml"
122
- - ".gitignore"
123
- - ".rubocop_todo.yml"
124
133
  - CHANGELOG.md
125
- - CONTRIBUTING.md
126
- - Gemfile
127
134
  - LICENSE.txt
128
135
  - README.md
129
- - Rakefile
130
- - bin/console
131
- - bin/setup
132
136
  - exe/gitlab
133
- - gitlab.gemspec
134
137
  - lib/gitlab.rb
135
138
  - lib/gitlab/api.rb
136
139
  - lib/gitlab/cli.rb
137
140
  - lib/gitlab/cli_helpers.rb
138
141
  - lib/gitlab/client.rb
139
142
  - lib/gitlab/client/access_requests.rb
143
+ - lib/gitlab/client/application_settings.rb
144
+ - lib/gitlab/client/avatar.rb
140
145
  - lib/gitlab/client/award_emojis.rb
141
146
  - lib/gitlab/client/boards.rb
142
147
  - lib/gitlab/client/branches.rb
@@ -144,15 +149,23 @@ files:
144
149
  - lib/gitlab/client/build_variables.rb
145
150
  - lib/gitlab/client/builds.rb
146
151
  - lib/gitlab/client/commits.rb
152
+ - lib/gitlab/client/container_registry.rb
147
153
  - lib/gitlab/client/deployments.rb
148
154
  - lib/gitlab/client/environments.rb
155
+ - lib/gitlab/client/epics.rb
149
156
  - lib/gitlab/client/events.rb
157
+ - lib/gitlab/client/features.rb
158
+ - lib/gitlab/client/group_boards.rb
159
+ - lib/gitlab/client/group_labels.rb
150
160
  - lib/gitlab/client/group_milestones.rb
151
161
  - lib/gitlab/client/groups.rb
162
+ - lib/gitlab/client/issue_links.rb
152
163
  - lib/gitlab/client/issues.rb
153
164
  - lib/gitlab/client/jobs.rb
154
165
  - lib/gitlab/client/keys.rb
155
166
  - lib/gitlab/client/labels.rb
167
+ - lib/gitlab/client/lint.rb
168
+ - lib/gitlab/client/markdown.rb
156
169
  - lib/gitlab/client/merge_request_approvals.rb
157
170
  - lib/gitlab/client/merge_requests.rb
158
171
  - lib/gitlab/client/milestones.rb
@@ -162,12 +175,17 @@ files:
162
175
  - lib/gitlab/client/pipeline_triggers.rb
163
176
  - lib/gitlab/client/pipelines.rb
164
177
  - lib/gitlab/client/project_badges.rb
178
+ - lib/gitlab/client/project_clusters.rb
179
+ - lib/gitlab/client/project_release_links.rb
180
+ - lib/gitlab/client/project_releases.rb
165
181
  - lib/gitlab/client/projects.rb
166
182
  - lib/gitlab/client/protected_tags.rb
167
183
  - lib/gitlab/client/repositories.rb
168
184
  - lib/gitlab/client/repository_files.rb
169
185
  - lib/gitlab/client/repository_submodules.rb
186
+ - lib/gitlab/client/resource_label_events.rb
170
187
  - lib/gitlab/client/runners.rb
188
+ - lib/gitlab/client/search.rb
171
189
  - lib/gitlab/client/services.rb
172
190
  - lib/gitlab/client/sidekiq.rb
173
191
  - lib/gitlab/client/snippets.rb
@@ -189,9 +207,9 @@ files:
189
207
  - lib/gitlab/shell.rb
190
208
  - lib/gitlab/shell_history.rb
191
209
  - lib/gitlab/version.rb
192
- homepage: https://github.com/narkoz/gitlab
210
+ homepage: https://github.com/NARKOZ/gitlab
193
211
  licenses:
194
- - BSD
212
+ - BSD-2-Clause
195
213
  metadata: {}
196
214
  post_install_message:
197
215
  rdoc_options: []
@@ -208,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
226
  - !ruby/object:Gem::Version
209
227
  version: '0'
210
228
  requirements: []
211
- rubygems_version: 3.0.1
229
+ rubygems_version: 3.0.6
212
230
  signing_key:
213
231
  specification_version: 4
214
232
  summary: A Ruby wrapper and CLI for the GitLab API
@@ -1,18 +0,0 @@
1
- # Number of days of inactivity before an issue becomes stale
2
- daysUntilStale: 90
3
- # Number of days of inactivity before a stale issue is closed
4
- daysUntilClose: 10
5
- # Issues with these labels will never be considered stale
6
- exemptLabels:
7
- - pinned
8
- - security
9
- - contribution welcome
10
- # Label to use when marking an issue as stale
11
- staleLabel: stale
12
- # Comment to post when marking an issue as stale. Set to `false` to disable
13
- markComment: >
14
- This issue has been automatically marked as stale because it has not had
15
- recent activity. It will be closed if no further activity occurs. Thank you
16
- for your contributions.
17
- # Comment to post when closing a stale issue. Set to `false` to disable
18
- closeComment: false
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- *.gem
2
- *.rbc
3
- *.swp
4
- .bundle
5
- .config
6
- .yardoc
7
- Gemfile.lock
8
- InstalledFiles
9
- _yardoc
10
- coverage
11
- doc/
12
- lib/bundler/man
13
- pkg
14
- rdoc
15
- spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
19
- vendor/bundle
20
- .idea
21
- .ruby-version
22
- .ruby-gemset
@@ -1,46 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-10-10 10:25:27 +0400 using RuboCop version 0.59.2.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- Lint/UriEscapeUnescape:
11
- Exclude:
12
- - 'lib/gitlab/client.rb'
13
-
14
- # Offense count: 5
15
- Metrics/AbcSize:
16
- Max: 34
17
-
18
- # Offense count: 4
19
- Metrics/CyclomaticComplexity:
20
- Max: 14
21
-
22
- # Offense count: 10
23
- # Configuration parameters: CountComments, ExcludedMethods.
24
- Metrics/MethodLength:
25
- Max: 34
26
-
27
- # Offense count: 2
28
- # Configuration parameters: CountComments.
29
- Metrics/ModuleLength:
30
- Max: 165
31
-
32
- # Offense count: 2
33
- # Configuration parameters: CountKeywordArgs.
34
- Metrics/ParameterLists:
35
- Max: 6
36
-
37
- # Offense count: 1
38
- Metrics/PerceivedComplexity:
39
- Max: 10
40
-
41
- # Offense count: 1
42
- # Cop supports --auto-correct.
43
- # Configuration parameters: AutoCorrect.
44
- Security/JSONLoad:
45
- Exclude:
46
- - 'lib/gitlab/request.rb'
@@ -1,195 +0,0 @@
1
- # Contributing to Gitlab
2
-
3
- Please take a moment to review this document in order to make the contribution
4
- process easy and effective for everyone involved!
5
-
6
- ## Using the issue tracker
7
-
8
- You can use the issues tracker for:
9
-
10
- * [bug reports](#bug-reports)
11
- * [feature requests](#feature-requests)
12
- * [submitting pull requests](#pull-requests)
13
-
14
- Use [Stackoverflow](http://stackoverflow.com/) for questions and personal support requests.
15
-
16
- ## Bug reports
17
-
18
- A bug is a _demonstrable problem_ that is caused by the code in the repository.
19
- Good bug reports are extremely helpful - thank you!
20
-
21
- Guidelines for bug reports:
22
-
23
- 1. **Use the GitHub issue search** &mdash; check if the issue has already been
24
- reported.
25
-
26
- 2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
27
- `master` branch in the repository.
28
-
29
- 3. **Isolate and report the problem** &mdash; ideally create a reduced test
30
- case.
31
-
32
- Please try to be as detailed as possible in your report. Include information about
33
- your Ruby, Gitlab client and GitLab instance versions. Please provide steps to
34
- reproduce the issue as well as the outcome you were expecting! All these details
35
- will help developers to fix any potential bugs.
36
-
37
- Example:
38
-
39
- > Short and descriptive example bug report title
40
- >
41
- > A summary of the issue and the environment in which it occurs. If suitable,
42
- > include the steps required to reproduce the bug.
43
- >
44
- > 1. This is the first step
45
- > 2. This is the second step
46
- > 3. Further steps, etc.
47
- >
48
- > Any other information you want to share that is relevant to the issue being
49
- > reported. This might include the lines of code that you have identified as
50
- > causing the bug, and potential solutions (and your opinions on their
51
- > merits).
52
-
53
- ## Feature requests
54
-
55
- Feature requests are welcome. But take a moment to find out whether your idea
56
- fits with the scope and aims of the project. It's up to *you* to make a strong
57
- case to convince the community of the merits of this feature.
58
- Please provide as much detail and context as possible.
59
-
60
- ## Contributing Documentation
61
-
62
- Code documentation has a special convention: it uses [YARD](http://yardoc.org/)
63
- formatting and the first paragraph is considered to be a short summary.
64
-
65
- For methods say what it will do. For example write something like:
66
-
67
- ```ruby
68
- # Reverses the contents of a String or IO object.
69
- #
70
- # @param [String, #read] contents the contents to reverse
71
- # @return [String] the contents reversed lexically
72
- def reverse(contents)
73
- contents = contents.read if contents.respond_to? :read
74
- contents.reverse
75
- end
76
- ```
77
-
78
- For classes, modules say what it is. For example write something like:
79
-
80
- ```ruby
81
- # Defines methods related to groups.
82
- module Groups
83
- ```
84
-
85
- Keep in mind that the documentation notes might show up in a summary somewhere,
86
- long texts in the documentation notes create very ugly summaries. As a rule of thumb
87
- anything longer than 80 characters is too long.
88
-
89
- Try to keep unnecessary details out of the first paragraph, it's only there to
90
- give a user a quick idea of what the documented "thing" does/is. The rest of the
91
- documentation notes can contain the details, for example parameters and what
92
- is returned.
93
-
94
- If possible include examples. For example:
95
-
96
- ```ruby
97
- # Gets information about a project.
98
- #
99
- # @example
100
- # Gitlab.project(3)
101
- # Gitlab.project('gitlab')
102
- #
103
- # @param [Integer, String] id The ID or name of a project.
104
- # @return [Gitlab::ObjectifiedHash]
105
- def project(id)
106
- ```
107
-
108
- This makes it easy to test the examples so that they don't go stale and examples
109
- are often a great help in explaining what a method does.
110
-
111
- ## Pull requests
112
-
113
- Good pull requests - patches, improvements, new features - are a fantastic
114
- help. They should remain focused in scope and avoid containing unrelated
115
- commits.
116
-
117
- **IMPORTANT**: By submitting a patch, you agree that your work will be
118
- licensed under the license used by the project.
119
-
120
- If you have any large pull request in mind (e.g. implementing features,
121
- refactoring code, etc), **please ask first** otherwise you risk spending
122
- a lot of time working on something that the project's developers might
123
- not want to merge into the project.
124
-
125
- Please adhere to the coding conventions in the project (indentation,
126
- accurate comments, etc.) and don't forget to add your own tests and
127
- documentation. When working with git, we recommend the following process
128
- in order to craft an excellent pull request:
129
-
130
- 1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork,
131
- and configure the remotes:
132
-
133
- ```sh
134
- # Clone your fork of the repo into the current directory
135
- git clone https://github.com/<your-username>/gitlab
136
- # Navigate to the newly cloned directory
137
- cd gitlab
138
- # Assign the original repo to a remote called "upstream"
139
- git remote add upstream https://github.com/NARKOZ/gitlab
140
- ```
141
-
142
- 2. If you cloned a while ago, get the latest changes from upstream:
143
-
144
- ```bash
145
- git checkout master
146
- git pull upstream master
147
- ```
148
-
149
- 3. Create a new topic branch (off of `master`) to contain your feature, change,
150
- or fix.
151
-
152
- **IMPORTANT**: Making changes in `master` is discouraged. You should always
153
- keep your local `master` in sync with upstream `master` and make your
154
- changes in topic branches.
155
-
156
- ```sh
157
- git checkout -b <topic-branch-name>
158
- ```
159
-
160
- 4. Commit your changes in logical chunks. Keep your commit messages organized,
161
- with a short description in the first line and more detailed information on
162
- the following lines. Feel free to use Git's
163
- [interactive rebase](https://help.github.com/articles/about-git-rebase/)
164
- feature to tidy up your commits before making them public.
165
-
166
- 5. Make sure all the tests are still passing.
167
-
168
- ```sh
169
- rake
170
- ```
171
-
172
- 6. Push your topic branch up to your fork:
173
-
174
- ```sh
175
- git push origin <topic-branch-name>
176
- ```
177
-
178
- 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
179
- with a clear title and description.
180
-
181
- 8. If you haven't updated your pull request for a while, you should consider
182
- rebasing on master and resolving any conflicts.
183
-
184
- **IMPORTANT**: _Never ever_ merge upstream `master` into your branches. You
185
- should always `git rebase` on `master` to bring your changes up to date when
186
- necessary.
187
-
188
- ```sh
189
- git checkout master
190
- git pull upstream master
191
- git checkout <your-topic-branch>
192
- git rebase master
193
- ```
194
-
195
- Thank you for your contributions!