Package list ruby-gitlab / c321896
New upstream version 4.5.0 Cédric Boutillier 3 years ago
219 changed file(s) with 1219 addition(s) and 7259 deletion(s). Raw diff Collapse all Expand all
+0
-8
.travis.yml less more
0 language: ruby
1 rvm:
2 - 2.0
3 - 2.1
4 - 2.2
5 - 2.3
6 - 2.4.0
7 before_install: gem update bundler
0 ## Change Log
1
2 ### Unreleased
0 ## CHANGELOG
1
2 ### Newer releases
3
4 Please see: https://github.com/NARKOZ/gitlab/releases
35
46 ### 4.2.0 (13/07/2017)
57 - Use `url_encode` in all `Commit` resources (@grodowski)
00 # Gitlab
11
2 [![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg?style=flat)](https://travis-ci.org/NARKOZ/gitlab)
3 [![Code Climate](https://img.shields.io/codeclimate/github/NARKOZ/gitlab.svg?style=flat)](https://codeclimate.com/github/NARKOZ/gitlab)
4 [![Inline docs](http://inch-ci.org/github/NARKOZ/gitlab.svg?style=flat)](https://inch-ci.org/github/NARKOZ/gitlab)
5 [![Gem version](https://img.shields.io/gem/v/gitlab.svg?style=flat)](https://rubygems.org/gems/gitlab)
6 [![License](https://img.shields.io/badge/license-BSD-red.svg?style=flat)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
2 [![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg)](https://travis-ci.org/NARKOZ/gitlab)
3 [![Code Climate](https://img.shields.io/codeclimate/maintainability/NARKOZ/gitlab.svg)](https://codeclimate.com/github/NARKOZ/gitlab)
4 [![Inline docs](http://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab)
5 [![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab)
6 [![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
77
88 [website](http://narkoz.github.io/gitlab) |
99 [documentation](http://rubydoc.info/gems/gitlab/frames) |
1010 [gitlab-live](https://github.com/NARKOZ/gitlab-live)
1111
12 Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html).
13 As of version `4.0.0` this gem will only support Ruby 2.0+ and Gitlab API v4.
12 Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html).
13 As of version `4.0.0` this gem only supports Ruby 2.0+ and Gitlab API v4.
1414
1515 ## Installation
1616
2525 ```ruby
2626 gem 'gitlab'
2727 # gem 'gitlab', github: 'NARKOZ/gitlab'
28 ```
29
30 Mac OS users can install using Homebrew:
31
32 ```sh
33 brew install gitlab-gem
2834 ```
2935
3036 ## Usage
174180
175181 ## Development
176182
183 ### With a dockerized Gitlab instance
184
185 ```shell
186 docker-compose up -d gitlab # Will start the gitlab instance in the background (approx. 3 minutes)
187 ```
188
189 After a while, your Gitlab instance will be accessible on http://localhost:3000.
190
191 Once you have set your new root password, you can login with the root user.
192
193 You can now setup a personal access token here: http://localhost:3000/profile/personal_access_tokens
194
195 Once you have your token, set the variables to the correct values in the `docker.env` file.
196
197 Then, launch the tool:
198
199 ```shell
200 docker-compose run app
201 ```
202
203 ```ruby
204 Gitlab.users
205 => [#<Gitlab::ObjectifiedHash:47231290771040 {hash: {"id"=>1, "name"=>"Administrator", "username"=>"root", ...]
206 ```
207
208 To launch the specs,
209
210 ```shell
211 docker-compose run app rake spec
212 ```
213
214 #### Want to use Gitlab Enterprise?
215
216 Just change the image from `gitlab/gitlab-ce:latest` to `gitlab/gitlab-ee:latest` in the `docker-compose.yml` file.
217
218 ### With an external Gitlab instance
219
220 First, set the variables to the correct values in the `docker.env` file.
221
222 Then, launch the tool:
223
224 ```shell
225 docker-compose run app
226 ```
227
228 ```ruby
229 Gitlab.users
230 => [#<Gitlab::ObjectifiedHash:47231290771040 {hash: {"id"=>1, "name"=>"Administrator", "username"=>"root", ...]
231 ```
232
233 To launch the specs,
234
235 ```shell
236 docker-compose run app rake spec
237 ```
238
239 ### Without Docker
240
177241 After checking out the repo, run `bin/setup` to install dependencies. Then, run
178242 `rake spec` to run the tests. You can also run `bin/console` for an interactive
179243 prompt that will allow you to experiment.
0 require "bundler/gem_tasks"
0 require 'bundler/gem_tasks'
11
22 require 'rspec/core/rake_task'
33 RSpec::Core::RakeTask.new(:spec) do |spec|
4 spec.pattern = FileList['spec/**/*_spec.rb']
54 spec.rspec_opts = ['--color', '--format d']
65 end
76
8 task default: :spec
7 require 'rubocop/rake_task'
8 RuboCop::RakeTask.new(:rubocop) do |task|
9 task.options = ['-D', '--parallel']
10 end
11
12 if ENV['TRAVIS_CI_RUBOCOP']
13 task default: :rubocop
14 else
15 task default: :spec
16 end
0 # -*- encoding: utf-8 -*-
10 lib = File.expand_path('../lib', __FILE__)
21 $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
32 require 'gitlab/version'
43
54 Gem::Specification.new do |gem|
6 gem.name = "gitlab"
5 gem.name = 'gitlab'
76 gem.version = Gitlab::VERSION
8 gem.authors = ["Nihad Abbasov"]
9 gem.email = ["mail@narkoz.me"]
10 gem.description = %q{Ruby client and CLI for GitLab API}
11 gem.summary = %q{A Ruby wrapper and CLI for the GitLab API}
12 gem.homepage = "https://github.com/narkoz/gitlab"
7 gem.authors = ['Nihad Abbasov', 'Sean Edge']
8 gem.email = ['mail@narkoz.me', 'asedge@gmail.com']
9 gem.description = 'Ruby client and CLI for GitLab API'
10 gem.summary = 'A Ruby wrapper and CLI for the GitLab API'
11 gem.homepage = 'https://github.com/narkoz/gitlab'
1312
14 gem.files = `git ls-files`.split($/)
15 gem.bindir = "exe"
13 gem.files = `git ls-files`.split($/).
14 reject { |f| f[/^spec/] } -
15 %w[Dockerfile docker-compose.yml docker.env .travis.yml .rubocop.yml .dockerignore]
16 gem.bindir = 'exe'
1617 gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
1718 gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18 gem.require_paths = ["lib"]
19 gem.license = "BSD"
19 gem.require_paths = ['lib']
20 gem.license = 'BSD'
2021
21 gem.required_ruby_version = ">= 2.0.0"
22 gem.required_ruby_version = '>= 2.0.0'
2223
23 gem.add_runtime_dependency 'httparty'
24 gem.add_runtime_dependency 'terminal-table'
24 gem.add_runtime_dependency 'httparty', '>= 0.14.0'
25 gem.add_runtime_dependency 'terminal-table', '>= 1.5.1'
2526
2627 gem.add_development_dependency 'pry'
2728 gem.add_development_dependency 'rake'
2829 gem.add_development_dependency 'rspec'
2930 gem.add_development_dependency 'webmock'
31 gem.add_development_dependency 'rubocop'
3032 end
1212 (Configuration::VALID_OPTIONS_KEYS + [:auth_token]).each do |key|
1313 send("#{key}=", options[key]) if options[key]
1414 end
15 set_request_defaults(@sudo)
15 request_defaults(@sudo)
16 self.class.headers 'User-Agent' => user_agent
1617 end
1718 end
1819 end
5151 end
5252
5353 unless valid_command?(cmd)
54 puts "Unknown command. Run `gitlab help` for a list of available commands."
54 puts 'Unknown command. Run `gitlab help` for a list of available commands.'
5555 exit(1)
5656 end
5757
58 if args.any? && (args.last.start_with?('--only=') || args.last.start_with?('--except='))
59 command_args = args[0..-2]
60 else
61 command_args = args
62 end
58 command_args = args.any? && args.last.start_with?('--only=', '--except=') ? args[0..-2] : args
6359
6460 begin
6561 command_args.map! { |arg| symbolize_keys(yaml_load(arg)) }
6666 #
6767 # @return [String]
6868 def confirm_command(cmd)
69 if cmd.start_with?('remove_') || cmd.start_with?('delete_')
70 puts "Are you sure? (y/n)"
71 if %w(y yes).include?($stdin.gets.to_s.strip.downcase)
72 puts 'Proceeding..'
73 else
74 puts 'Command aborted.'
75 exit(1)
76 end
69 return unless cmd.start_with?('remove_', 'delete_')
70
71 puts 'Are you sure? (y/n)'
72
73 if %w(y yes).include?($stdin.gets.to_s.strip.downcase)
74 puts 'Proceeding..'
75 else
76 puts 'Command aborted.'
77 exit(1)
7778 end
7879 end
7980
101102 end
102103
103104 def output_json(cmd, args, data)
104 if data.empty?
105 if data.respond_to?(:empty?) && data.empty?
105106 puts '{}'
106107 else
107108 hash_result = case data
108 when Gitlab::ObjectifiedHash,Gitlab::FileResponse
109 when Gitlab::ObjectifiedHash, Gitlab::FileResponse
109110 record_hash([data], cmd, args, true)
110111 when Gitlab::PaginatedResponse
111112 record_hash(data, cmd, args)
112113 else
113114 { cmd: cmd, data: data, args: args }
114 end
115 end
115116 puts JSON.pretty_generate(hash_result)
116117 end
117118 end
134135 keys.each do |key|
135136 case value = hash[key]
136137 when Hash
137 value = value.has_key?('id') ? value['id'] : 'Hash'
138 value = value.key?('id') ? value['id'] : 'Hash'
138139 when StringIO
139140 value = 'File'
140141 when nil
193194 # Helper function to get rows and keys from data returned from API call
194195 def get_keys(args, data)
195196 arr = data.map(&:to_h)
196 keys = arr.first.keys.sort { |x, y| x.to_s <=> y.to_s }
197 keys = arr.first.keys.sort_by(&:to_s)
197198 keys &= required_fields(args) if required_fields(args).any?
198199 keys -= excluded_fields(args)
199200 [arr, keys]
219220 begin
220221 newhash[key.to_sym] = symbolize_keys(value)
221222 rescue NoMethodError
222 raise "error: cannot convert hash key to symbol: #{key}"
223 raise "Error: cannot convert hash key to symbol: #{key}"
223224 end
224225 end
225226 end
229230
230231 # YAML::load on a single argument
231232 def yaml_load(arg)
232 begin
233 yaml = YAML.load(arg)
234 rescue Psych::SyntaxError
235 raise "error: Argument is not valid YAML syntax: #{arg}"
236 end
237 yaml
233 YAML.safe_load(arg)
234 rescue Psych::SyntaxError
235 raise "Error: Argument is not valid YAML syntax: #{arg}"
238236 end
239237 end
240238 end
0 class Gitlab::Client
1 # Defines methods related to Award Emojis.
2 # @see https://docs.gitlab.com/ce/api/access_requests.html
3 module AccessRequests
4 # Gets a list of access requests for a project viewable by the authenticated user.
5 #
6 # @example
7 # Gitlab.project_access_requests(1)
8 #
9 # @param [Integer, String] :project(required) The ID or name of a project.
10 # @return [Array<Gitlab::ObjectifiedHash>] List of project access requests
11 def project_access_requests(project)
12 get("/projects/#{url_encode project}/access_requests")
13 end
14 # Gets a list of access requests for a group viewable by the authenticated user.
15 #
16 # @example
17 # Gitlab.group_access_requests(1)
18 #
19 # @param [Integer, String] :group(required) The ID or name of a group.
20 # @return [Array<Gitlab::ObjectifiedHash>] List of group access requests
21 def group_access_requests(group)
22 get("/groups/#{url_encode group}/access_requests")
23 end
24 # Requests access for the authenticated user to a project.
25 #
26 # @example
27 # Gitlab.request_project_access(1)
28 #
29 # @param [Integer, String] :project(required) The ID or name of a project.
30 # @return <Gitlab::ObjectifiedHash] Information about the requested project access
31 def request_project_access(project)
32 post("/projects/#{url_encode project}/access_requests")
33 end
34 # Requests access for the authenticated user to a group.
35 #
36 # @example
37 # Gitlab.request_group_access(1)
38 #
39 # @param [Integer, String] :group(required) The ID or name of a group.
40 # @return <Gitlab::ObjectifiedHash] Information about the requested group access
41 def request_group_access(group)
42 post("/groups/#{url_encode group}/access_requests")
43 end
44 # Approves a project access request for the given user.
45 #
46 # @example
47 # Gitlab.approve_project_access_request(1, 1)
48 # Gitlab.approve_project_access_request(1, 1, {access_level: '30'})
49 #
50 # @param [Integer, String] :project(required) The ID or name of a project.
51 # @param [Integer] :user_id(required) The user ID of the access requester
52 # @option options [Integer] :access_level(optional) A valid access level (defaults: 30, developer access level)
53 # @return <Gitlab::ObjectifiedHash] Information about the approved project access request
54 def approve_project_access_request(project, user_id, options = {})
55 put("/projects/#{url_encode project}/access_requests/#{user_id}/approve", body: options)
56 end
57 # Approves a group access request for the given user.
58 #
59 # @example
60 # Gitlab.approve_group_access_request(1, 1)
61 # Gitlab.approve_group_access_request(1, 1, {access_level: '30'})
62 #
63 # @param [Integer, String] :group(required) The ID or name of a group.
64 # @param [Integer] :user_id(required) The user ID of the access requester
65 # @option options [Integer] :access_level(optional) A valid access level (defaults: 30, developer access level)
66 # @return <Gitlab::ObjectifiedHash] Information about the approved group access request
67 def approve_group_access_request(group, user_id, options = {})
68 put("/groups/#{url_encode group}/access_requests/#{user_id}/approve", body: options)
69 end
70 # Denies a project access request for the given user.
71 #
72 # @example
73 # Gitlab.deny_project_access_request(1, 1)
74 #
75 # @param [Integer, String] :project(required) The ID or name of a project.
76 # @param [Integer] :user_id(required) The user ID of the access requester
77 # @return [void] This API call returns an empty response body.
78 def deny_project_access_request(project, user_id)
79 delete("/projects/#{url_encode project}/access_requests/#{user_id}")
80 end
81 # Denies a group access request for the given user.
82 #
83 # @example
84 # Gitlab.deny_group_access_request(1, 1)
85 #
86 # @param [Integer, String] :group(required) The ID or name of a group.
87 # @param [Integer] :user_id(required) The user ID of the access requester
88 # @return [void] This API call returns an empty response body.
89 def deny_group_access_request(group, user_id)
90 delete("/groups/#{url_encode group}/access_requests/#{user_id}")
91 end
92 end
93 end
2626 # @param [String] branch The name of the branch.
2727 # @return [Gitlab::ObjectifiedHash]
2828 def branch(project, branch)
29 get("/projects/#{url_encode project}/repository/branches/#{branch}")
29 get("/projects/#{url_encode project}/repository/branches/#{url_encode branch}")
3030 end
3131 alias_method :repo_branch, :branch
3232
4646 # @option options [Boolean] :developers_can_merge True to allow developers to merge into the branch (default = false)
4747 # @return [Gitlab::ObjectifiedHash] Details about the branch
4848 def protect_branch(project, branch, options = {})
49 put("/projects/#{url_encode project}/repository/branches/#{branch}/protect", body: options)
49 post("/projects/#{url_encode project}/protected_branches", body: {name: branch}.merge(options))
5050 end
5151 alias_method :repo_protect_branch, :protect_branch
5252
6060 # @param [String] branch The name of the branch.
6161 # @return [Gitlab::ObjectifiedHash] Details about the branch
6262 def unprotect_branch(project, branch)
63 put("/projects/#{url_encode project}/repository/branches/#{branch}/unprotect")
63 delete("/projects/#{url_encode project}/protected_branches/#{url_encode branch}")
6464 end
6565 alias_method :repo_unprotect_branch, :unprotect_branch
6666
6767 # Creates a repository branch. Requires Gitlab >= 6.8.x
6868 #
6969 # @example
70 # Gitlab.create_branch(3, 'api')
71 # Gitlab.repo_create_branch(5, 'master')
70 # Gitlab.create_branch(3, 'api', 'feat/new-api')
71 # Gitlab.repo_create_branch(5, 'master', 'develop')
7272 #
7373 # @param [Integer, String] project The ID or name of a project.
7474 # @param [String] branch The name of the new branch.
7575 # @param [String] ref Create branch from commit sha or existing branch
7676 # @return [Gitlab::ObjectifiedHash] Details about the branch
7777 def create_branch(project, branch, ref)
78 post("/projects/#{url_encode project}/repository/branches", body: { branch: branch, ref: ref })
78 post("/projects/#{url_encode project}/repository/branches", query: { branch: branch, ref: ref })
7979 end
8080 alias_method :repo_create_branch, :create_branch
8181
8888 # @param [Integer, String] project The ID or name of a project.
8989 # @param [String] branch The name of the branch to delete
9090 def delete_branch(project, branch)
91 delete("/projects/#{url_encode project}/repository/branches/#{branch}")
91 delete("/projects/#{url_encode project}/repository/branches/#{url_encode branch}")
9292 end
9393 alias_method :repo_delete_branch, :delete_branch
9494 end
00 class Gitlab::Client
11 # Defines methods related to builds.
22 # @see https://docs.gitlab.com/ce/api/build_variables.html
3 # @see https://docs.gitlab.com/ee/api/group_level_variables.html
34 module BuildVariables
45 # Gets a list of the project's build variables
56 #
1516 # Gets details of a project's specific build variable.
1617 #
1718 # @example
18 # Gitlab.build(5, "TEST_VARIABLE_1")
19 # Gitlab.variable(5, "TEST_VARIABLE_1")
1920 #
2021 # @param [Integer, String] project The ID or name of a project.
2122 # @param [String] key The key of a variable.
4041 # Update a project's build variable.
4142 #
4243 # @example
43 # Gitlab.create_variable(5, "NEW_VARIABLE", "updated value")
44 # Gitlab.update_variable(5, "NEW_VARIABLE", "updated value")
4445 #
4546 # @param [Integer, String] project The ID or name of a project.
4647 # @param [String] key The key of a variable
6162 def remove_variable(project, key)
6263 delete("/projects/#{url_encode project}/variables/#{key}")
6364 end
65
66 # Gets a list of the group's build variables
67 #
68 # @example
69 # Gitlab.group_variables(5)
70 #
71 # @param [Integer, String] group The ID or name of a group.
72 # @return [Array<Gitlab::ObjectifiedHash>] The list of variables.
73 def group_variables(group)
74 get("/groups/#{url_encode group}/variables")
75 end
76
77 # Gets details of a group's specific build variable.
78 #
79 # @example
80 # Gitlab.group_variable(5, "TEST_VARIABLE_1")
81 #
82 # @param [Integer, String] group The ID or name of a group.
83 # @param [String] key The key of a variable.
84 # @return [Gitlab::ObjectifiedHash] The variable.
85 def group_variable(group, key)
86 get("/groups/#{url_encode group}/variables/#{key}")
87 end
88
89 # Create a build variable for a group.
90 #
91 # @example
92 # Gitlab.create_group_variable(5, "NEW_VARIABLE", "new value")
93 #
94 # @param [Integer, String] group The ID or name of a group.
95 # @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
96 # @param [String] value The value of a variable
97 # @return [Gitlab::ObjectifiedHash] The variable.
98 def create_group_variable(group, key, value)
99 post("/groups/#{url_encode group}/variables", body: { key: key, value: value })
100 end
101
102 # Update a group's build variable.
103 #
104 # @example
105 # Gitlab.update_group_variable(5, "NEW_VARIABLE", "updated value")
106 #
107 # @param [Integer, String] group The ID or name of a group.
108 # @param [String] key The key of a variable
109 # @param [String] value The value of a variable
110 # @return [Gitlab::ObjectifiedHash] The variable.
111 def update_group_variable(group, key, value)
112 put("/groups/#{url_encode group}/variables/#{key}", body: { value: value })
113 end
114
115 # Remove a group's build variable.
116 #
117 # @example
118 # Gitlab.remove_group_variable(5, "VARIABLE_1")
119 #
120 # @param [Integer, String] group The ID or name of a group.
121 # @param [String] key The key of a variable.
122 # @return [Gitlab::ObjectifiedHash] The variable.
123 def remove_group_variable(group, key)
124 delete("/groups/#{url_encode group}/variables/#{key}")
125 end
64126 end
65127 end
141141 }.merge(options)
142142 post("/projects/#{url_encode project}/repository/commits", body: payload)
143143 end
144
145 # Gets a list of merge requests for a commit.
146 #
147 # @see https://docs.gitlab.com/ce/api/commits.html#list-merge-requests-associated-with-a-commit
148 # Introduced in Gitlab 10.7
149 #
150 # @example
151 # Gitlab.commit_merge_requests(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
152 #
153 # @param [Integer] project The ID of a project.
154 # @param [String] sha The commit hash.
155 # @option options [Integer] :page The page number.
156 # @option options [Integer] :per_page The number of results per page.
157 # @return [Array<Gitlab::ObjectifiedHash>]
158 def commit_merge_requests(project, commit, options={})
159 get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: options)
160 end
161 alias_method :repo_commit_merge_requests, :commit_merge_requests
144162 end
145163 end
0 class Gitlab::Client
1 # Defines methods related to deployments.
2 # @see https://docs.gitlab.com/ce/api/deployments.html
3 module Deployments
4 # Gets a list of project deployments.
5 #
6 # @example
7 # Gitlab.deployments(5)
8 # Gitlab.deployments(5, { per_page: 10, page: 2 })
9 #
10 # @param [Integer, String] project The ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @option options [Integer] :page The page number.
13 # @option options [Integer] :per_page The number of results per page.
14 # @return [Array<Gitlab::ObjectifiedHash>]
15 def deployments(project, options={})
16 get("/projects/#{url_encode project}/deployments", query: options)
17 end
18
19 # Gets a single deployment.
20 #
21 # @example
22 # Gitlab.deployment(5, 36)
23 #
24 # @param [Integer, String] project The ID or name of a project.
25 # @param [Integer] id The ID of an deployment.
26 # @return [Gitlab::ObjectifiedHash]
27 def deployment(project, id)
28 get("/projects/#{url_encode project}/deployments/#{id}")
29 end
30 end
31 end
0 class Gitlab::Client
1 # Defines methods related to events.
2 # @see https://docs.gitlab.com/ce/api/events.html
3 module Events
4 # Gets a list of authenticated user's events
5 #
6 # @example
7 # Gitlab.events()
8 # Gitlab.events({ action: 'created', target_type: 'issue' })
9 #
10 # @param [Hash] options A customizable set of options.
11 # @option options [String] :action Only events of specific action type
12 # @option options [String] :target_type Only events of specific target type
13 # @option options [String] :before Only events created before YYYY-MM-DD
14 # @option options [String] :after Only events created after YYYY-MM-DD
15 # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
16 # @return [Array<Gitlab::ObjectifiedHash>]
17 def events(options={})
18 get('/events', query: options)
19 end
20
21 # Gets a list of user contribution events
22 #
23 # @example
24 # Gitlab.user_events(1)
25 # Gitlab.user_events(1, { action: created})
26 #
27 # @param [Integer, String] user The ID or username of user
28 # @param [Hash] options A customizable set of options.
29 # @option options [String] :action Only events of specific action type
30 # @option options [String] :target_type Only events of specific target type
31 # @option options [String] :before Only events created before YYYY-MM-DD
32 # @option options [String] :after Only events created after YYYY-MM-DD
33 # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
34 # @return [Array<Gitlab::ObjectifiedHash>]
35 def user_events(user, options={})
36 get("/users/#{url_encode user}/events", query: options)
37 end
38
39 # Gets a list of visible project events
40 #
41 # @example
42 # Gitlab.project_events(1)
43 # Gitlab.project_events(1, { action: created })
44 #
45 # @param [Integer] project The ID of project
46 # @param [Hash] options A customizable set of options.
47 # @option options [String] :action Only events of specific action type
48 # @option options [String] :target_type Only events of specific target type
49 # @option options [String] :before Only events created before YYYY-MM-DD
50 # @option options [String] :after Only events created after YYYY-MM-DD
51 # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
52 # @return [Array<Gitlab::ObjectifiedHash>]
53 def project_events(project, options={})
54 get("/#{url_encode project}/events", query: options)
55 end
56 end
57 end
0 class Gitlab::Client
1 # Defines methods related to group milestones.
2 # @see https://docs.gitlab.com/ee/api/group_milestones.html
3 module GroupMilestones
4 # Gets a list of a group's milestones.
5 #
6 # @example
7 # Gitlab.group_milestones(5)
8 #
9 # @param [Integer, String] id The ID or name of a group.
10 # @param [Hash] options A customizable set of options.
11 # @option options [Integer] :page The page number.
12 # @option options [Integer] :per_page The number of results per page.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def group_milestones(id, options={})
15 get("/groups/#{url_encode id}/milestones", query: options)
16 end
17
18 # Gets a single group milestone.
19 #
20 # @example
21 # Gitlab.group_milestone(5, 36)
22 #
23 # @param [Integer, String] id The ID or name of a group.
24 # @param [Integer] milestone_id The ID of a milestone.
25 # @return [Gitlab::ObjectifiedHash]
26 def group_milestone(id, milestone_id)
27 get("/groups/#{url_encode id}/milestones/#{milestone_id}")
28 end
29
30 # Creates a new group milestone.
31 #
32 # @example
33 # Gitlab.create_group_milestone(5, 'v1.0')
34 #
35 # @param [Integer, String] id The ID or name of a group.
36 # @param [String] title The title of a milestone.
37 # @param [Hash] options A customizable set of options.
38 # @option options [String] :description The description of a milestone.
39 # @option options [String] :due_date The due date of a milestone.
40 # @return [Gitlab::ObjectifiedHash] Information about created milestone.
41 def create_group_milestone(id, title, options={})
42 body = { title: title }.merge(options)
43 post("/groups/#{url_encode id}/milestones", body: body)
44 end
45
46 # Updates a group milestone.
47 #
48 # @example
49 # Gitlab.edit_group_milestone(5, 2, { state_event: 'activate' })
50 #
51 # @param [Integer, String] id The ID or name of a group.
52 # @param [Integer] milestone_id The ID of a milestone.
53 # @param [Hash] options A customizable set of options.
54 # @option options [String] :title The title of a milestone.
55 # @option options [String] :description The description of a milestone.
56 # @option options [String] :due_date The due date of a milestone.
57 # @option options [String] :state_event The state of a milestone ('close' or 'activate').
58 # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
59 def edit_group_milestone(id, milestone_id, options={})
60 put("/groups/#{url_encode id}/milestones/#{milestone_id}", body: options)
61 end
62
63 # Gets the issues of a given group milestone.
64 #
65 # @example
66 # Gitlab.group_milestone_issues(5, 2)
67 #
68 # @param [Integer, String] id The ID or name of a group.
69 # @param [Integer, String] milestone_id The ID of a milestone.
70 # @option options [Integer] :page The page number.
71 # @option options [Integer] :per_page The number of results per page.
72 # @return [Array<Gitlab::ObjectifiedHash>]
73 def group_milestone_issues(id, milestone_id, options={})
74 get("/groups/#{url_encode id}/milestones/#{milestone_id}/issues", query: options)
75 end
76
77 # Gets the merge_requests of a given group milestone.
78 #
79 # @example
80 # Gitlab.group_milestone_merge_requests(5, 2)
81 #
82 # @param [Integer, String] group The ID or name of a group.
83 # @param [Integer, String] milestone_id The ID of a milestone.
84 # @option options [Integer] :page The page number.
85 # @option options [Integer] :per_page The number of results per page.
86 # @return [Array<Gitlab::ObjectifiedHash>]
87 def group_milestone_merge_requests(id, milestone_id, options={})
88 get("/groups/#{url_encode id}/milestones/#{milestone_id}/merge_requests", query: options)
89 end
90 end
91 end
92
2323 # @param [Integer] id The ID of a group.
2424 # @return [Gitlab::ObjectifiedHash]
2525 def group(id)
26 get("/groups/#{id}")
26 get("/groups/#{url_encode id}")
2727 end
2828
2929 # Creates a new group.
4747 # @param [Integer] id The ID of a group
4848 # @return [Gitlab::ObjectifiedHash] Information about the deleted group.
4949 def delete_group(id)
50 delete("/groups/#{id}")
50 delete("/groups/#{url_encode id}")
5151 end
5252
5353 # Get a list of group members.
6262 # @option options [Integer] :per_page The number of results per page.
6363 # @return [Array<Gitlab::ObjectifiedHash>]
6464 def group_members(id, options={})
65 get("/groups/#{id}/members", query: options)
65 get("/groups/#{url_encode id}/members", query: options)
66 end
67
68 # Get details of a single group member.
69 #
70 # @example
71 # Gitlab.group_member(1, 10)
72 #
73 # @param [Integer] team_id The ID of the group to find a member in.
74 # @param [Integer] user_id The user id of the member to find.
75 # @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
76 def group_member(team_id, user_id)
77 get("/groups/#{url_encode team_id}/members/#{user_id}")
6678 end
6779
6880 # Adds a user to group.
7587 # @param [Integer] access_level Project access level.
7688 # @return [Gitlab::ObjectifiedHash] Information about added team member.
7789 def add_group_member(team_id, user_id, access_level)
78 post("/groups/#{team_id}/members", body: { user_id: user_id, access_level: access_level })
90 post("/groups/#{url_encode team_id}/members", body: { user_id: user_id, access_level: access_level })
7991 end
8092
8193 # Edit a user of a group.
88100 # @param [Integer] access_level Project access level.
89101 # @return [Gitlab::ObjectifiedHash] Information about edited team member.
90102 def edit_group_member(team_id, user_id, access_level)
91 put("/groups/#{team_id}/members/#{user_id}", body: { access_level: access_level })
103 put("/groups/#{url_encode team_id}/members/#{user_id}", body: { access_level: access_level })
92104 end
93105
94106 # Removes user from user group.
100112 # @param [Integer] user_id The ID of a user.
101113 # @return [Gitlab::ObjectifiedHash] Information about removed team member.
102114 def remove_group_member(team_id, user_id)
103 delete("/groups/#{team_id}/members/#{user_id}")
115 delete("/groups/#{url_encode team_id}/members/#{user_id}")
104116 end
105117
106118 # Transfers a project to a group
112124 # @param [Integer] project_id The ID of a project.
113125 def transfer_project_to_group(id, project_id)
114126 body = { id: id, project_id: project_id }
115 post("/groups/#{id}/projects/#{project_id}", body: body)
127 post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
116128 end
117129
118130 # Search for groups by name
137149 # @param [Integer] id The ID of a group
138150 # @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
139151 def group_projects(id, options={})
140 get("/groups/#{id}/projects", query: options)
152 get("/groups/#{url_encode id}/projects", query: options)
153 end
154
155 # Get a list of subgroups under a group
156 # @example
157 # Gitlab.group_subgroups(1)
158 #
159 # @param [Integer] id the ID of a group
160 # @param [Hash] options A customizable set of options.
161 # @option options [String] :skip_groups Skip the group IDs passed.
162 # @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
163 # @option options [String] :search Return the list of authorized groups matching the search criteria.
164 # @option options [String] :order_by Order groups by name or path. Default is name.
165 # @option options [String] :sort Order groups in asc or desc order. Default is asc.
166 # @option options [String] :statistics Include group statistics (admins only).
167 # @option options [String] :owned Limit to groups owned by the current user.
168 # @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
169 def group_subgroups(id, options={})
170 get("/groups/#{url_encode id}/subgroups", query: options)
171 end
172
173 # Updates an existing group.
174 #
175 # @example
176 # Gitlab.edit_group(42)
177 # Gitlab.edit_group(42, { name: 'Group Name' })
178 #
179 # @param [Integer] group The ID.
180 # @param [Hash] options A customizable set of options
181 # @option options [String] :name The name of the group.
182 # @option options [String] :path The path of the group.
183 # @option options [String] :description The description of the group.
184 # @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
185 # @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
186 # @option options [String] :request_access_enabled Allow users to request member access.
187 # @return [Gitlab::ObjectifiedHash] Information about the edited group.
188 def edit_group(id, options={})
189 put("/groups/#{url_encode id}", body: options)
141190 end
142191 end
143192 end
132132 def delete_issue(project, id)
133133 delete("/projects/#{url_encode project}/issues/#{id}")
134134 end
135
136 # Move an issue.
137 #
138 # @example
139 # Gitlab.move_issue(3, 42, { to_project_id: '4' })
140 #
141 # @param [Integer, String] project The ID or name of a project.
142 # @param [Integer] id The ID of an issue.
143 # @option options [String] :to_project_id The ID of the new project.
144 # @return [Gitlab::ObjectifiedHash] Information about moved issue.
145 def move_issue(project, id, options={})
146 post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
147 end
148
149 # Sets an estimated time of work for an issue.
150 #
151 # @example
152 # Gitlab.estimate_time_of_issue(3, 42, '3h30m')
153 #
154 # @param [Integer, String] project The ID or name of a project.
155 # @param [Integer] id The ID of an issue.
156 # @param [String] duration The duration in human format. e.g: 3h30m
157 def estimate_time_of_issue(project, id, duration)
158 post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
159 end
160
161 # Resets the estimated time for an issue to 0 seconds.
162 #
163 # @example
164 # Gitlab.reset_time_estimate_of_issue(3, 42)
165 #
166 # @param [Integer, String] project The ID or name of a project.
167 # @param [Integer] id The ID of an issue.
168 def reset_time_estimate_of_issue(project, id)
169 post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
170 end
171
172 # Adds spent time for an issue
173 #
174 # @example
175 # Gitlab.estimate_time_of_issue(3, 42, '3h30m')
176 #
177 # @param [Integer, String] project The ID or name of a project.
178 # @param [Integer] id The ID of an issue.
179 # @param [String] duration The time spent in human format. e.g: 3h30m
180 def add_time_spent_on_issue(project, id, duration)
181 post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) })
182 end
183
184 # Resets the total spent time for this issue to 0 seconds.
185 #
186 # @example
187 # Gitlab.reset_time_spent_on_issue(3, 42)
188 #
189 # @param [Integer, String] project The ID or name of a project.
190 # @param [Integer] id The ID of an issue.
191 def reset_time_spent_on_issue(project, id)
192 post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
193 end
194
195 # Get time tracking stats for an issue
196 #
197 # @example
198 # @gitlab.time_stats_for_issue(3, 42)
199 #
200 # @param [Integer, String] project The ID or name of a project.
201 # @param [Integer] id The ID of an issue.
202 def time_stats_for_issue(project, id)
203 get("/projects/#{url_encode project}/issues/#{id}/time_stats")
204 end
205
135206 end
136207 end
88 #
99 # @param [Integer, String] project The ID or name of a project.
1010 # @return [Array<Gitlab::ObjectifiedHash>]
11 def labels(project)
12 get("/projects/#{url_encode project}/labels")
11 def labels(project, options={})
12 get("/projects/#{url_encode project}/labels", query: options)
1313 end
1414
1515 # Creates a new label.
0 class Gitlab::Client
1 # Defines methods related to MR Approvals.
2 # @see https://docs.gitlab.com/ee/api/merge_request_approvals.html
3 module MergeRequestApprovals
4 # Gets MR Approval Configuration for a project
5 #
6 # @example
7 # Gitlab.project_merge_request_approvals(1)
8 #
9 # @param [Integer] project The ID of a project.
10 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
11 def project_merge_request_approvals(project)
12 get("/projects/#{url_encode project}/approvals")
13 end
14
15 # Change MR Approval Configuration for a project
16 #
17 # @example
18 # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3})
19 # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, reset_approvals_on_push: true})
20 # Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, disable_overriding_approvers_per_merge_request: false})
21 #
22 # @param [Integer] project(required) The ID of a project.
23 # @option options [Integer] :approvals_before_merge(optional) How many approvals are required before an MR can be merged
24 # @option options [Boolean] :reset_approvals_on_push(optional) Reset approvals on a new push
25 # @option options [Boolean] :disable_overriding_approvers_per_merge_request(optional) Allow/Disallow overriding approvers per MR
26 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
27 def edit_project_merge_request_approvals(project, options = {})
28 post("/projects/#{url_encode project}/approvals", body: options)
29 end
30
31 # Change allowed approvers and approver groups for a project
32 #
33 # @example
34 # Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
35 #
36 # @param [Integer] project(required) The ID of a project.
37 # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
38 # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
39 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
40 def edit_project_approvers(project, options = {})
41 put("/projects/#{url_encode project}/approvals", body: options)
42 end
43
44 # Get Configuration for approvals on a specific Merge Request.
45 #
46 # @example
47 # Gitlab.merge_request_approvals(1, 5)
48 #
49 # @param [Integer] project(required) The ID of a project.
50 # @param [Integer] merge_request(required) The IID of a merge_request.
51 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the merge request
52 def merge_request_approvals(project, merge_request)
53 get("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals")
54 end
55
56 # Change configuration for approvals on a specific merge request.
57 #
58 # @example
59 # Gitlab.edit_merge_request_approvals(1, 5, approvals_required: 2)
60 #
61 # @param [Integer] project(required) The ID of a project.
62 # @param [Integer] merge_request(required) The IID of a merge_request.
63 # @option options [Integer] :approvals_required(required) Approvals required before MR can be merged
64 # @return [Gitlab::ObjectifiedHash] Updated MR approval configuration information about the merge request
65 def edit_merge_request_approvals(project, merge_request, options = {})
66 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
67 end
68
69 # Change allowed approvers and approver groups for a merge request
70 #
71 # @example
72 # Gitlab.edit_merge_request_approvers(1, 5, {approver_ids: [5], approver_groups: [1]})
73 #
74 # @param [Integer] project(required) The ID of a project.
75 # @param [Integer] merge_request(required) The IID of a merge_request.
76 # @option options [Array] :approver_ids(optional) An array of User IDs that can approve MRs
77 # @option options [Array] :approver_group_ids(optional) An array of Group IDs whose members can approve MRs
78 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
79 def edit_merge_request_approvers(project, merge_request, options = {})
80 put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
81 end
82
83 # Approve a merge request
84 #
85 # @example
86 # Gitlab.approve_merge_request(1, 5)
87 # Gitlab.approve_merge_request(1, 5, sha: 'fe678da')
88 #
89 # @param [Integer] project(required) The ID of a project.
90 # @param [Integer] merge_request(required) The IID of a merge request.
91 # @option options [String] :sha(optional) The HEAD of the MR
92 # @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
93 def approve_merge_request(project, merge_request, options = {})
94 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approve", body: options)
95 end
96
97 # Unapprove a merge request
98 #
99 # @example
100 # Gitlab.unapprove_merge_request(1, 5)
101 #
102 # @param [Integer] project(required) The ID of a project.
103 # @param [Integer] merge_request(required) The IID of a merge request.
104 # @return [void] This API call returns an empty response body.
105 def unapprove_merge_request(project, merge_request)
106 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove")
107 end
108 end
109 end
11 # Defines methods related to merge requests.
22 # @see https://docs.gitlab.com/ce/api/merge_requests.html
33 module MergeRequests
4 # Gets a list of all of the merge requests the authenticated user has access to.
5 #
6 # @example
7 # Gitlab.user_merge_requests
8 # Gitlab.user_merge_requests(state: :opened, scope: :all)
9 #
10 # @param [Hash] options A customizable set of options.
11 # @return [Array<Gitlab::ObjectifiedHash>]
12 def user_merge_requests(options = {})
13 get('/merge_requests', query: options)
14 end
15
416 # Gets a list of project merge requests.
517 #
618 # @example
719 # Gitlab.merge_requests(5)
8 # Gitlab.merge_requests({ per_page: 40 })
20 # Gitlab.merge_requests(5, { per_page: 40 })
921 #
1022 # @param [Integer, String] project The ID or name of a project.
1123 # @param [Hash] options A customizable set of options.
4355 # @option options [String] :target_branch (required) The target branch name.
4456 # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
4557 # @option options [Integer] :target_project_id (optional) The target project ID.
58 # @option options [String] :labels (optional) Labels as a comma-separated list.
4659 # @return [Gitlab::ObjectifiedHash] Information about created merge request.
4760 def create_merge_request(project, title, options={})
4861 body = { title: title }.merge(options)
141154 def unsubscribe_from_merge_request(project, id)
142155 post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe")
143156 end
157
158 # List project merge request discussions
159 #
160 # @example
161 # Gitlab.merge_request_discussions(5, 1)
162 # Gitlab.merge_request_discussions('gitlab', 1)
163 # @param [Integer, String] project The ID or name of a project.
164 # @param [Integer] id The ID of a merge request.
165 # @return [Gitlab::ObjectifiedHash] List of the merge request discussions.
166 def merge_request_discussions(project, merge_request_id)
167 get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions")
168 end
169
170 # Get single merge request discussion
171 #
172 # @example
173 # Gitlab.merge_request_discussion(5, 1, 1)
174 # Gitlab.merge_request_discussion('gitlab', 1, 1)
175 # @param [Integer, String] project The ID or name of a project.
176 # @param [Integer] id The ID of a merge request.
177 # @param [Integer] discussion_id The ID of a discussion.
178 # @return [Gitlab::ObjectifiedHash] The merge request discussion.
179 def merge_request_discussion(project, merge_request_id, discussion_id)
180 get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}")
181 end
182
183 # Create new merge request discussion
184 #
185 # @example
186 # Gitlab.create_merge_request_discussion(5, 1, body: 'discuss')
187 # Gitlab.create_merge_request_discussion('gitlab', 1, body: 'discuss')
188 # @param [Integer, String] project The ID or name of a project.
189 # @param [Integer] id The ID of a merge request.
190 # @param [Hash] options A customizable set of options.
191 # * :body (String) The content of a discussion
192 # * :created_at (String) Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z
193 # * :position (Hash) Position when creating a diff note
194 # * :base_sha (String) Base commit SHA in the source branch
195 # * :start_sha (String) SHA referencing commit in target branch
196 # * :head_sha (String) SHA referencing HEAD of this merge request
197 # * :position_type (String) Type of the position reference', allowed values: 'text' or 'image'
198 # * :new_path (String) File path after change
199 # * :new_line (Integer) Line number after change (for 'text' diff notes)
200 # * :old_path (String) File path before change
201 # * :old_line (Integer) Line number before change (for 'text' diff notes)
202 # * :width (Integer) Width of the image (for 'image' diff notes)
203 # * :height (Integer) Height of the image (for 'image' diff notes)
204 # * :x (Integer) X coordinate (for 'image' diff notes)
205 # * :y (Integer) Y coordinate (for 'image' diff notes)
206 # @return [Gitlab::ObjectifiedHash] The created merge request discussion.
207 def create_merge_request_discussion(project, merge_request_id, options={})
208 post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", body: options)
209 end
210
211 # Resolve a merge request discussion
212 #
213 # @example
214 # Gitlab.resolve_merge_request_discussion(5, 1, 1, true)
215 # Gitlab.resolve_merge_request_discussion('gitlab', 1, 1, false)
216 # @param [Integer, String] project The ID or name of a project.
217 # @param [Integer] id The ID of a merge request.
218 # @param [Integer] discussion_id The ID of a discussion.
219 # @param [Hash] options A customizable set of options.
220 # @option options [Boolean] :resolved Resolve/unresolve the discussion.
221 # @return [Gitlab::ObjectifiedHash] The merge request discussion.
222 def resolve_merge_request_discussion(project, merge_request_id, discussion_id, options)
223 put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}", body: options)
224 end
225
226 # Add note to existing merge request discussion
227 #
228 # @example
229 # Gitlab.create_merge_request_discussion_note(5, 1, 1, note_id: 1, body: 'note')
230 # Gitlab.create_merge_request_discussion_note('gitlab', 1, 1, note_id: 1, body: 'note')
231 # @param [Integer, String] project The ID or name of a project.
232 # @param [Integer] id The ID of a merge request.
233 # @param [Integer] discussion_id The ID of a discussion.
234 # @param [Hash] options A customizable set of options.
235 # @option options [Integer] :note_id The ID of a discussion note.
236 # @option options [String] :body The content of a discussion.
237 # @option options [String] :created_at Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z.
238 # @return [Gitlab::ObjectifiedHash] The merge request discussion note.
239 def create_merge_request_discussion_note(project, merge_request_id, discussion_id, options)
240 post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes", body: options)
241 end
242
243 # Modify an existing merge request discussion note
244 #
245 # @example
246 # Gitlab.update_merge_request_discussion_note(5, 1, 1, 1, body: 'note')
247 # Gitlab.update_merge_request_discussion_note('gitlab', 1, 1, 1, body: 'note')
248 # @param [Integer, String] project The ID or name of a project.
249 # @param [Integer] id The ID of a merge request.
250 # @param [Integer] discussion_id The ID of a discussion.
251 # @param [Integer] note_id The ID of a discussion note.
252 # @param [Hash] options A customizable set of options.
253 # @option options [String] :body The content of a discussion.
254 # @option options [Boolean] :resolved Resolve/unresolve the note.
255 # @return [Gitlab::ObjectifiedHash] The merge request discussion note.
256 def update_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id, options)
257 put("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}", body: options)
258 end
259
260 # Delete a merge request discussion note
261 #
262 # @example
263 # Gitlab.delete_merge_request_discussion_note(5, 1, 1, 1)
264 # Gitlab.delete_merge_request_discussion_note('gitlab', 1, 1, 1)
265 # @param [Integer, String] project The ID or name of a project.
266 # @param [Integer] id The ID of a merge request.
267 # @param [Integer] discussion_id The ID of a discussion.
268 # @param [Integer] note_id The ID of a discussion note.
269 # @return [Gitlab::ObjectifiedHash] An empty response.
270 def delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id)
271 delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
272 end
144273 end
145274 end
218218 #
219219 # @param [Integer] project The ID of a project.
220220 # @param [Integer] id The ID of a note.
221 # @param [String] body The content of a note.
221222 # @return [Gitlab::ObjectifiedHash]
222223 def edit_note(project, id, body)
223 put("/projects/#{url_encode project}/notes/#{id}", body: body)
224 put("/projects/#{url_encode project}/notes/#{id}", body: note_content(body))
224225 end
225226
226227 # Modifies an issue note.
231232 # @param [Integer] project The ID of a project.
232233 # @param [Integer] issue The ID of an issue.
233234 # @param [Integer] id The ID of a note.
235 # @param [String] body The content of a note.
234236 # @return [Gitlab::ObjectifiedHash]
235237 def edit_issue_note(project, issue, id, body)
236 put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: body)
238 put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: note_content(body))
237239 end
238240
239241 # Modifies a snippet note.
244246 # @param [Integer] project The ID of a project.
245247 # @param [Integer] snippet The ID of a snippet.
246248 # @param [Integer] id The ID of a note.
249 # @param [String] body The content of a note.
247250 # @return [Gitlab::ObjectifiedHash]
248251 def edit_snippet_note(project, snippet, id, body)
249 put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: body)
252 put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: note_content(body))
250253 end
251254
252255 # Modifies a merge_request note.
257260 # @param [Integer] project The ID of a project.
258261 # @param [Integer] merge_request The ID of a merge_request.
259262 # @param [Integer] id The ID of a note.
263 # @param [String] body The content of a note.
260264 # @return [Gitlab::ObjectifiedHash]
261265 def edit_merge_request_note(project, merge_request, id, body)
262 put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: body)
266 put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body))
263267 end
264268 alias_method :edit_merge_request_comment, :edit_merge_request_note
269
270 private
271
272 # TODO: Remove this method after a couple deprecation cycles. Replace calls with the code
273 # in the 'else'.
274 def note_content(body)
275 if body.is_a?(Hash)
276 STDERR.puts "Passing the note body as a Hash is deprecated. You should just pass the String."
277 body
278 else
279 { body: body }
280 end
281 end
265282 end
266283 end
0 class Gitlab::Client
1 # Defines methods related to pipeline schedules.
2 # @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
3 module PipelineSchedules
4 # Gets a list of project pipeline schedules.
5 #
6 # @example
7 # Gitlab.pipeline_schedules(5)
8 # Gitlab.pipeline_schedules(5, { scope: 'active' })
9 #
10 # @param [Integer, String] project the ID or name of a project.
11 # @param [Hash] options A customizable set of options.
12 # @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
13 # @return [Array<Gitlab::ObjectifiedHash>]
14 def pipeline_schedules(project, options={})
15 get("/projects/#{url_encode project}/pipeline_schedules", query: options)
16 end
17
18 # Gets a single pipeline schedule.
19 #
20 # @example
21 # Gitlab.pipeline_schedule(5, 3)
22 #
23 # @param [Integer, String] project The ID or name of a project.
24 # @param [Integer] id The ID of the pipeline schedule.
25 # @return [Gitlab::ObjectifiedHash]
26 def pipeline_schedule(project, id)
27 get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
28 end
29
30 # Create a pipeline schedule.
31 #
32 # @example
33 # Gitlab.create_pipeline_schedule(5, { description: 'example' })
34 #
35 # @param [Integer, String] project The ID or name of a project.
36 # @param [Hash] options A customizable set of options.
37 # @option options [String] :description The description of pipeline scehdule.
38 # @option options [String] :ref The branch/tag name will be triggered.
39 # @option options [String] :cron The cron (e.g. 0 1 * * *).
40 # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
41 # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
42 # @return [Array<Gitlab::ObjectifiedHash>]
43 def create_pipeline_schedule(project, options={})
44 post("/projects/#{url_encode project}/pipeline_schedules", query: options)
45 end
46
47 # Updates the pipeline schedule of a project.
48 #
49 # @example
50 # Gitlab.edit_pipeline_schedule(3, 2, { description: 'example2' })
51 #
52 # @param [Integer, String] project The ID or name of a project.
53 # @param [Integer] The pipeline schedule ID.
54 # @param [Hash] options A customizable set of options.
55 # @option options [String] :description The description of pipeline scehdule.
56 # @option options [String] :ref The branch/tag name will be triggered.
57 # @option options [String] :cron The cron (e.g. 0 1 * * *).
58 # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
59 # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
60 # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
61 def edit_pipeline_schedule(project, pipeline_schedule_id, options={})
62 put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", query: options)
63 end
64
65 # Take ownership of a pipeline schedule.
66 #
67 # @example
68 # Gitlab.pipeline_schedule_take_ownership(5, 1)
69 #
70 # @param [Integer, String] project The ID or name of a project.
71 # @param [Integer] trigger_id The pipeline schedule ID.
72 # @return [Gitlab::ObjectifiedHash] The updated pipeline schedule.
73 def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
74 post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
75 end
76
77 # Delete a pipeline schedule.
78 #
79 # @example
80 # Gitlab.delete_pipeline_schedule(5, 1)
81 #
82 # @param [Integer, String] project The ID or name of a project.
83 # @param [Integer] trigger_id The pipeline schedule ID.
84 # @return [Gitlab::ObjectifiedHash] The deleted pipeline schedule.
85 def delete_pipeline_schedule(project, pipeline_schedule_id)
86 delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}")
87 end
88
89 # Create a pipeline schedule variable.
90 #
91 # @example
92 # Gitlab.create_pipeline_schedule_variable(5, 1, { key: 'foo', value: 'bar' })
93 #
94 # @param [Integer, String] project The ID or name of a project.
95 # @param [Integer] trigger_id The pipeline schedule ID.
96 # @param [Hash] options A customizable set of options.
97 # @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed.
98 # @option options [String] :value The value of a variable
99 # @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
100 def create_pipeline_schedule_variable(project, pipeline_schedule_id, options={})
101 post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", query: options)
102 end
103
104 # Updates the variable of a pipeline schedule.
105 #
106 # @example
107 # Gitlab.edit_pipeline_schedule_variable(3, 2, "foo" { value: 'bar' })
108 #
109 # @param [Integer, String] project The ID or name of a project.
110 # @param [Integer] The pipeline schedule ID.
111 # @param [String] The key of a variable.
112 # @param [Hash] options A customizable set of options.
113 # @option options [String] :value The value of a variable.
114 # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
115 def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={})
116 put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", query: options)
117 end
118
119 # Delete the variable of a pipeline schedule
120 #
121 # @example
122 # Gitlab.delete_pipeline_schedule_variable(3, 2, "foo")
123 #
124 # @param [Integer, String] project The ID or name of a project.
125 # @param [Integer] The pipeline schedule ID.
126 # @param [String] The key of a variable.
127 # @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
128 def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={})
129 delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
130 end
131 end
132 end
7979 # Run the given project pipeline trigger.
8080 #
8181 # @example
82 # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master')
83 # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
82 # Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master')
83 # Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
8484 #
8585 # @see https://docs.gitlab.com/ce/ci/triggers/README.html
8686 #
99 # @param [Hash] options A customizable set of options.
1010 # @option options [Integer] :page The page number.
1111 # @option options [Integer] :per_page The number of results per page.
12 # @option options [String] :scope Scope of projects. 'owned' for list of projects owned by the authenticated user, 'all' to get all projects (admin only)
12 # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#list-all-projects Gitlab docs} for all valid options)
13 #
1314 # @return [Array<Gitlab::ObjectifiedHash>]
1415 def projects(options={})
15 if options[:scope]
16 get("/projects/#{options[:scope]}", query: options)
17 else
18 get("/projects", query: options)
19 end
16 get("/projects", query: options)
2017 end
2118
2219 # Search for projects by name.
4744 # @return [Gitlab::ObjectifiedHash]
4845 def project(id)
4946 get("/projects/#{url_encode id}")
50 end
51
52 # Gets a list of project events.
53 #
54 # @example
55 # Gitlab.project_events(42)
56 # Gitlab.project_events('gitlab')
57 #
58 # @param [Integer, String] project The ID or path of a project.
59 # @param [Hash] options A customizable set of options.
60 # @option options [Integer] :page The page number.
61 # @option options [Integer] :per_page The number of results per page.
62 # @return [Array<Gitlab::ObjectifiedHash>]
63 def project_events(project, options={})
64 get("/projects/#{url_encode project}/events", query: options)
6547 end
6648
6749 # Creates a new project.
297279 #
298280 # @param [Integer] id The ID of a project.
299281 # @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
300 def delete_push_rule(id, options={})
282 def delete_push_rule(id)
301283 delete("/projects/#{url_encode id}/push_rule")
302284 end
303285
354336 # Creates a new deploy key.
355337 #
356338 # @example
357 # Gitlab.create_deploy_key(42, 'My Key', 'Key contents')
339 # Gitlab.create_deploy_key(42, 'My Key', 'Key contents', can_push: true)
358340 #
359341 # @param [Integer, String] project The ID or path of a project.
360342 # @param [String] title The title of a deploy key.
361343 # @param [String] key The content of a deploy key.
344 # @param [Hash] options A customizable set of options.
362345 # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
363 def create_deploy_key(project, title, key)
364 post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key })
346 def create_deploy_key(project, title, key, options = {})
347 post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge(options))
365348 end
366349
367350 # Enables a deploy key at the project.
412395 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
413396 def create_fork(id, options={})
414397 post("/projects/#{url_encode id}/fork", body: options)
398 end
399
400 # Get a list of all visible projects across GitLab for the authenticated user.
401 # When accessed without authentication, only public projects are returned.
402 #
403 # Note: This feature was introduced in GitLab 10.1
404 #
405 # @example
406 # Gitlab.project_forks(42)
407 #
408 # @param [Hash] options A customizable set of options.
409 # @option options [Integer] :page The page number.
410 # @option options [Integer] :per_page The number of results per page.
411 # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
412 # @option options [String] :sort Return requests sorted in asc or desc order
413 # @return [Array<Gitlab::ObjectifiedHash>]
414 def project_forks(id, options={})
415 get("/projects/#{url_encode id}/forks", query: options)
415416 end
416417
417418 # Updates an existing project.
445446 post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
446447 end
447448
449 # Unshare project with group.
450 #
451 # @example
452 # Gitlab.unshare_project_with_group('gitlab', 2)
453 #
454 # @param [Integer, String] project The ID or path of a project.
455 # @param [Integer] id The ID of a group.
456 # @return [void] This API call returns an empty response body.
457 def unshare_project_with_group(project, id)
458 delete("/projects/#{url_encode project}/share/#{id}")
459 end
460
448461 # Stars a project.
449462 # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
450463 #
470483 def unstar_project(id)
471484 delete("/projects/#{url_encode id}/star")
472485 end
486
487 # Get a list of visible projects for the given user.
488 # @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
489 #
490 # @example
491 # Gitlab.user_projects(1)
492 # Gitlab.user_projects(1, { order_by: 'last_activity_at' })
493 # Gitlab.user_projects('username', { order_by: 'name', sort: 'asc' })
494 #
495 # @param [Integer, String] user_id The ID or username of the user.
496 # @param [Hash] options A customizable set of options.
497 # @option options [String] :per_page Number of projects to return per page
498 # @option options [String] :page The page to retrieve
499 # @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
500 # @option options [String] :sort Return projects sorted in asc or desc order.
501 # @return [Array<Gitlab::ObjectifiedHash>]
502 def user_projects(user_id, options={})
503 get("/users/#{url_encode user_id}/projects", query: options)
504 end
473505 end
474506 end
1414 # @param [String] ref The name of a repository branch or tag or if not given the default branch.
1515 # @return [String]
1616 def file_contents(project, filepath, ref='master')
17 ref = URI.encode(ref, /\W/)
1817 get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw",
1918 query: { ref: ref},
2019 format: nil,
9493 # @option options [String] :author_email Commit author's email address
9594 # @return [Gitlab::ObjectifiedHash]
9695 def remove_file(project, path, branch, commit_message, options = {})
97 delete("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: {
96 delete("/projects/#{url_encode project}/repository/files/#{url_encode path}",
97 body: {
9898 branch: branch,
9999 commit_message: commit_message
100100 }.merge(options))
7171 delete("/runners/#{id}")
7272 end
7373
74 # Gets a list of Jobs for a Runner
75 #
76 # @example
77 # Gitlab.runner_jobs(1)
78 #
79 # @param [Integer] id The ID of a runner.
80 # @return [Array<Gitlab::ObjectifiedHash>]
81 def runner_jobs(runner_id)
82 get("/runners/#{url_encode runner_id}/jobs")
83 end
84
7485 # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
7586 # @see https://docs.gitlab.com/ce/api/runners.html#list-projects-runners
7687 #
0 class Gitlab::Client
1 # Defines methods related to sidekiq metrics.
2 # @see https://docs.gitlab.com/ce/api/sidekiq_metrics.html
3 module Sidekiq
4 # Get the current Queue Metrics
5 #
6 # @example
7 # Gitlab.sidekiq_queue_metrics
8 def sidekiq_queue_metrics
9 get('/sidekiq/queue_metrics')
10 end
11
12 # Get the current Process Metrics
13 #
14 # @example
15 # Gitlab.sidekiq_process_metrics
16 def sidekiq_process_metrics
17 get('/sidekiq/process_metrics')
18 end
19
20 # Get the current Job Statistics
21 #
22 # @example
23 # Gitlab.sidekiq_job_stats
24 def sidekiq_job_stats
25 get('/sidekiq/job_stats')
26 end
27
28 # Get a compound response of all the previously mentioned metrics
29 #
30 # @example
31 # Gitlab.sidekiq_compound_metrics
32 def sidekiq_compound_metrics
33 get('/sidekiq/compound_metrics')
34 end
35 end
36 end
3030 # Creates a new snippet.
3131 #
3232 # @example
33 # Gitlab.create_snippet(42, { title: 'REST', file_name: 'api.rb', code: 'some code' })
33 # Gitlab.create_snippet(42, { title: 'REST', file_name: 'api.rb', code: 'some code', visibility: 'public'})
3434 #
3535 # @param [Integer, String] project The ID or name of a project.
3636 # @param [Hash] options A customizable set of options.
3838 # @option options [String] :file_name (required) The name of a snippet file.
3939 # @option options [String] :code (required) The content of a snippet.
4040 # @option options [String] :lifetime (optional) The expiration date of a snippet.
41 # @option options [String] :visibility (required) The visibility of a snippet
4142 # @return [Gitlab::ObjectifiedHash] Information about created snippet.
4243 def create_snippet(project, options={})
4344 post("/projects/#{url_encode project}/snippets", body: options)
5556 # @option options [String] :file_name The name of a snippet file.
5657 # @option options [String] :code The content of a snippet.
5758 # @option options [String] :lifetime The expiration date of a snippet.
59 # @option options [String] :visibility (optional) The visibility of a snippet
5860 # @return [Gitlab::ObjectifiedHash] Information about updated snippet.
5961 def edit_snippet(project, id, options={})
6062 put("/projects/#{url_encode project}/snippets/#{id}", body: options)
2929 # @param [String] description Optional release notes for tag.
3030 # @return [Gitlab::ObjectifiedHash]
3131 def create_tag(project, tag_name, ref, message='', description=nil)
32 post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, description: description })
32 post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, release_description: description })
3333 end
3434 alias_method :repo_create_tag, :create_tag
3535
4343 # @param [String] tag The name of the tag.
4444 # @return [Gitlab::ObjectifiedHash]
4545 def tag(project, tag)
46 get("/projects/#{url_encode project}/repository/tags/#{tag}")
46 get("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
4747 end
4848 alias_method :repo_tag, :tag
4949
5757 # @param [String] tag The name of the tag to delete
5858 # @return [Gitlab::ObjectifiedHash]
5959 def delete_tag(project, tag)
60 delete("/projects/#{url_encode project}/repository/tags/#{tag}")
60 delete("/projects/#{url_encode project}/repository/tags/#{url_encode tag}")
6161 end
6262 alias_method :repo_delete_tag, :delete_tag
6363
7272 # @param [String] description Release notes with markdown support
7373 # @return [Gitlab::ObjectifiedHash]
7474 def create_release(project, tag, description)
75 post("/projects/#{url_encode project}/repository/tags/#{tag}/release", body: { description: description })
75 post("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
7676 end
7777 alias_method :repo_create_release, :create_release
7878
8787 # @param [String] description Release notes with markdown support
8888 # @return [Gitlab::ObjectifiedHash]
8989 def update_release(project, tag, description)
90 put("/projects/#{url_encode project}/repository/tags/#{tag}/release", body: { description: description })
90 put("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description })
9191 end
9292 alias_method :repo_update_release, :update_release
9393
4848 # @return [Gitlab::ObjectifiedHash] Information about created user.
4949 def create_user(*args)
5050 options = Hash === args.last ? args.pop : {}
51 if args[2]
52 body = { email: args[0], password: args[1], username: args[2] }
53 else
54 body = { email: args[0], password: args[1], name: args[0] }
55 end
51 body = if args[2]
52 { email: args[0], password: args[1], username: args[2] }
53 else
54 { email: args[0], password: args[1], name: args[0] }
55 end
5656 body.merge!(options)
5757 post('/users', body: body)
5858 end
22 class Client < API
33 Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
44
5 # Please keep in alphabetical order
6 include AccessRequests
57 include AwardEmojis
68 include Boards
79 include Branches
10 include BuildVariables
811 include Builds
9 include BuildVariables
1012 include Commits
13 include Deployments
1114 include Environments
15 include Events
16 include GroupMilestones
1217 include Groups
1318 include Issues
19 include Jobs
1420 include Keys
1521 include Labels
22 include MergeRequestApprovals
1623 include MergeRequests
1724 include Milestones
1825 include Namespaces
1926 include Notes
27 include PipelineSchedules
28 include PipelineTriggers
2029 include Pipelines
21 include PipelineTriggers
2230 include Projects
2331 include Repositories
2432 include RepositoryFiles
2533 include Runners
2634 include Services
35 include Sidekiq
2736 include Snippets
2837 include SystemHooks
2938 include Tags
3039 include Todos
3140 include Users
32 include Jobs
3341
3442 # Text representation of the client, masking private token.
3543 #
4553 end
4654
4755 def url_encode(s)
48 ERB::Util.url_encode(s)
56 URI.encode(s.to_s, /\W/)
4957 end
5058
5159 private
5260
5361 def only_show_last_four_chars(token)
54 "#{'*'*(token.size - 4)}#{token[-4..-1]}"
62 "#{'*' * (token.size - 4)}#{token[-4..-1]}"
5563 end
5664 end
5765 end
22 # Defines constants and methods related to configuration.
33 module Configuration
44 # An array of valid keys in the options hash when configuring a Gitlab::API.
5 VALID_OPTIONS_KEYS = [:endpoint, :private_token, :user_agent, :sudo, :httparty].freeze
5 VALID_OPTIONS_KEYS = %i(endpoint private_token user_agent sudo httparty).freeze
66
77 # The user agent that will be sent to the API endpoint if none is set.
88 DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}".freeze
4747
4848 httparty = Gitlab::CLI::Helpers.yaml_load(options)
4949
50 raise ArgumentError, "HTTParty config should be a Hash." unless httparty.is_a? Hash
50 raise ArgumentError, 'HTTParty config should be a Hash.' unless httparty.is_a? Hash
5151 Gitlab::CLI::Helpers.symbolize_keys httparty
5252 end
5353 end
1010
1111 # Custom error class for rescuing from HTTP response errors.
1212 class ResponseError < Error
13 POSSIBLE_MESSAGE_KEYS = %i(message error_description error)
14
1315 def initialize(response)
1416 @response = response
1517 super(build_error_message)
1618 end
1719
18 # Status code returned in the http response.
20 # Status code returned in the HTTP response.
1921 #
2022 # @return [Integer]
2123 def response_status
2224 @response.code
25 end
26
27 # Body content returned in the HTTP response
28 #
29 # @return [String]
30 def response_message
31 @response.parsed_response.message
2332 end
2433
2534 private
2938 # @return [String]
3039 def build_error_message
3140 parsed_response = @response.parsed_response
32 message = parsed_response.message || parsed_response.error
33
41 message = check_error_keys(parsed_response)
3442 "Server responded with code #{@response.code}, message: " \
3543 "#{handle_message(message)}. " \
3644 "Request URI: #{@response.request.base_uri}#{@response.request.path}"
45 end
46
47 # Error keys vary across the API, find the first key that the parsed_response
48 # object responds to and return that, otherwise return the original.
49 def check_error_keys(resp)
50 key = POSSIBLE_MESSAGE_KEYS.find { |k| resp.respond_to?(k) }
51 key ? resp.send(key) : resp
3752 end
3853
3954 # Handle error response message in case of nested hashes
3838
3939 # Parse filename from the 'Content Disposition' header.
4040 def parse_headers!(headers)
41 @filename = headers[HEADER_CONTENT_DISPOSITION].split("filename=")[1]
41 @filename = headers[HEADER_CONTENT_DISPOSITION].split('filename=')[1]
4242 @filename = @filename[1...-1] if @filename[0] == '"' # Unquote filenames
4343 end
4444 end
3232 def ri_cmd
3333 which_ri = `which ri`.chomp
3434 if which_ri.empty?
35 fail "'ri' tool not found in $PATH. Please install it to use the help."
35 raise "'ri' tool not found in $PATH. Please install it to use the help."
3636 end
3737
3838 which_ri
6060 def actions_table(topic=nil)
6161 rows = topic ? help_map[topic] : help_map.keys
6262 table do |t|
63 t.title = topic || "Help Topics"
63 t.title = topic || 'Help Topics'
6464
6565 # add_row expects an array and we have strings hence the map.
6666 rows.sort.map { |r| [r] }.each_with_index do |row, index|
7272
7373 # Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd)
7474 def namespace(cmd)
75 method_owners.select { |method| method[:name] === cmd }.
75 method_owners.select { |method| method[:name] == cmd }.
7676 map { |method| method[:owner] + '.' + method[:name] }.
7777 shift
7878 end
8181 def change_help_output!(cmd, output_str)
8282 output_str.gsub!(/#{cmd}\((.*?)\)/m, cmd + ' \1')
8383 output_str.gsub!(/\,[\s]*/, ' ')
84
84
8585 # Ensure @option descriptions are on a single line
8686 output_str.gsub!(/\n\[/, " \[")
8787 output_str.gsub!(/\s(@)/, "\n@")
8888 output_str.gsub!(/(\])\n(\:)/, '\1 \2')
8989 output_str.gsub!(/(\:.*)(\n)(.*\.)/, '\1 \3')
9090 output_str.gsub!(/\{(.+)\}/, '"{\1}"')
91
9291 end
93 end # class << self
92 end
9493 end
55 HEADER_LINK = 'Link'.freeze
66 DELIM_LINKS = ','.freeze
77 LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"/
8 METAS = %w(last next first prev)
8 METAS = %w(last next first prev).freeze
99
1010 attr_accessor(*METAS)
1111
2424 LINK_REGEX.match(link.strip) do |match|
2525 url, meta = match[1], match[2]
2626 next if !url || !meta || METAS.index(meta).nil?
27 self.send("#{meta}=", url)
27 send("#{meta}=", url)
2828 end
2929 end
3030 end
2525 elsif body.nil?
2626 false
2727 else
28 raise Error::Parsing.new "Couldn't parse a response body"
28 raise Error::Parsing, "Couldn't parse a response body"
2929 end
3030 end
3131
3232 # Decodes a JSON response into Ruby object.
3333 def self.decode(response)
34 JSON.load response
34 return response ? JSON.load(response) : {}
3535 rescue JSON::ParserError
36 raise Error::Parsing.new "The response is not a valid JSON"
36 raise Error::Parsing, 'The response is not a valid JSON'
3737 end
3838
39 def get(path, options={})
40 set_httparty_config(options)
41 set_authorization_header(options)
42 validate self.class.get(@endpoint + path, options)
43 end
44
45 def post(path, options={})
46 set_httparty_config(options)
47 set_authorization_header(options)
48 validate self.class.post(@endpoint + path, options)
49 end
50
51 def put(path, options={})
52 set_httparty_config(options)
53 set_authorization_header(options)
54 validate self.class.put(@endpoint + path, options)
55 end
56
57 def delete(path, options={})
58 set_httparty_config(options)
59 set_authorization_header(options)
60 validate self.class.delete(@endpoint + path, options)
39 %w(get post put delete).each do |method|
40 define_method method do |path, options={}|
41 httparty_config(options)
42 authorization_header(options)
43 validate self.class.send(method, @endpoint + path, options)
44 end
6145 end
6246
6347 # Checks the response code for common errors.
6448 # Returns parsed response for successful requests.
6549 def validate(response)
6650 error_klass = case response.code
67 when 400 then Error::BadRequest
68 when 401 then Error::Unauthorized
69 when 403 then Error::Forbidden
70 when 404 then Error::NotFound
71 when 405 then Error::MethodNotAllowed
72 when 409 then Error::Conflict
73 when 422 then Error::Unprocessable
74 when 500 then Error::InternalServerError
75 when 502 then Error::BadGateway
76 when 503 then Error::ServiceUnavailable
77 end
51 when 400 then Error::BadRequest
52 when 401 then Error::Unauthorized
53 when 403 then Error::Forbidden
54 when 404 then Error::NotFound
55 when 405 then Error::MethodNotAllowed
56 when 409 then Error::Conflict
57 when 422 then Error::Unprocessable
58 when 500 then Error::InternalServerError
59 when 502 then Error::BadGateway
60 when 503 then Error::ServiceUnavailable
61 end
7862
79 fail error_klass.new(response) if error_klass
63 raise error_klass, response if error_klass
8064
8165 parsed = response.parsed_response
8266 parsed.client = self if parsed.respond_to?(:client=)
8670
8771 # Sets a base_uri and default_params for requests.
8872 # @raise [Error::MissingCredentials] if endpoint not set.
89 def set_request_defaults(sudo=nil)
73 def request_defaults(sudo=nil)
9074 self.class.default_params sudo: sudo
91 raise Error::MissingCredentials.new("Please set an endpoint to API") unless @endpoint
75 raise Error::MissingCredentials, 'Please set an endpoint to API' unless @endpoint
9276 self.class.default_params.delete(:sudo) if sudo.nil?
9377 end
9478
9983 # @param [Hash] options A customizable set of options.
10084 # @option options [Boolean] :unauthenticated true if the API call does not require user authentication.
10185 # @raise [Error::MissingCredentials] if private_token and auth_token are not set.
102 def set_authorization_header(options)
103 unless options[:unauthenticated]
104 raise Error::MissingCredentials.new("Please provide a private_token or auth_token for user") unless @private_token
105 if @private_token.length <= 20
106 options[:headers] = { 'PRIVATE-TOKEN' => @private_token }
107 else
108 options[:headers] = { 'Authorization' => "Bearer #{@private_token}" }
109 end
110 end
86 def authorization_header(options)
87 return if options[:unauthenticated]
88 raise Error::MissingCredentials, 'Please provide a private_token or auth_token for user' unless @private_token
89
90 options[:headers] = if @private_token.size < 21
91 { 'PRIVATE-TOKEN' => @private_token }
92 else
93 { 'Authorization' => "Bearer #{@private_token}" }
94 end
11195 end
11296
11397 # Set HTTParty configuration
11498 # @see https://github.com/jnunemaker/httparty
115 def set_httparty_config(options)
99 def httparty_config(options)
116100 options.merge!(httparty) if httparty
117101 end
118102 end
6262
6363 # Execute a given command with arguements
6464 def execute(cmd=command, args=arguments)
65 if actions.include?(cmd.to_sym)
66 confirm_command(cmd)
67 gitlab_helper(cmd, args)
68 else
69 fail "Unknown command: #{cmd}. " \
70 "See the 'help' for a list of valid commands."
71 end
65 raise "Unknown command: #{cmd}. See the 'help' for a list of valid commands." unless actions.include?(cmd.to_sym)
66
67 confirm_command(cmd)
68 gitlab_helper(cmd, args)
7269 end
7370
7471 def quit_shell
7976 def history
8077 @history ||= History.new
8178 end
82 end # class << self
79 end
8380 end
00 module Gitlab
1 VERSION = "4.2.0"
1 VERSION = '4.5.0'.freeze
22 end
2525 end
2626
2727 # Delegate to Gitlab::Client
28 def respond_to_missing?(method_name, include_private = false)
28 def self.respond_to_missing?(method_name, include_private=false)
2929 client.respond_to?(method_name) || super
3030 end
3131
3838 #
3939 # @return [Array<Symbol>]
4040 def self.actions
41 hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|set_request_defaults|httparty/
41 hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|request_defaults|httparty/
4242 (Gitlab::Client.instance_methods - Object.methods).reject { |e| e[hidden] }
4343 end
4444 end
+0
-1
spec/fixtures/board_list.json less more
0 { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }
+0
-1
spec/fixtures/board_lists.json less more
0 [ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }, { "id" : 2, "label" : { "name" : "Ready", "color" : "#FF0000", "description" : null }, "position" : 2 }, { "id" : 3, "label" : { "name" : "Production", "color" : "#FF5F00", "description" : null }, "position" : 3 } ]
+0
-1
spec/fixtures/boards.json less more
0 [ { "id" : 1, "lists" : [ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }, { "id" : 2, "label" : { "name" : "Ready", "color" : "#FF0000", "description" : null }, "position" : 2 }, { "id" : 3, "label" : { "name" : "Production", "color" : "#FF5F00", "description" : null }, "position" : 3 } ] } ]
+0
-1
spec/fixtures/branch.json less more
0 {"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"},"protected": true}
+0
-3
spec/fixtures/branch_delete.json less more
0 {
1 "branch_name": "api"
2 }
+0
-1
spec/fixtures/branches.json less more
0 [{"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"}},{"name":"dashboard-feed","commit":{"id":"f8f6ff065eccc6ede4d35ed87a09bb962b84ca25","parents":[{"id":"2cf8010792c3075824ee27d0f037aeb178cbbf7e"}],"tree":"e17f2157143d550891d4669c10b7446e4739bc6d","message":"add projects atom feed","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-05-31T23:42:02-07:00","committed_date":"2012-05-31T23:42:02-07:00"}},{"name":"master","commit":{"id":"2cf8010792c3075824ee27d0f037aeb178cbbf7e","parents":[{"id":"af226ae9c9af406c8a0e0bbdf364563495c2f432"},{"id":"e851cb07762aa464aae10e8b4b28de87c1a6f925"}],"tree":"6c6845838039f01723d91f395a1d2fa1dcc82522","message":"Merge pull request #868 from SaitoWu/bugfix/encoding\n\nBugfix/encoding","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-05-30T00:24:43-07:00","committed_date":"2012-05-30T00:24:43-07:00"}},{"name":"preview_notes","commit":{"id":"3749e0d99ac6bfbc65889b1b7a5310e14e7fe89a","parents":[{"id":"2483181f2c3d4ea7d2c68147b19bc07fc3937b0c"}],"tree":"f8c56161b0d6561568f088df9961362eb1ece88b","message":"pass project_id to notes preview path","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-08-09T23:46:27-07:00","committed_date":"2012-08-09T23:46:27-07:00"}},{"name":"refactoring","commit":{"id":"7c7761099cae83f59fe5780340e100be890847b2","parents":[{"id":"058d80b3363dd4fc4417ca4f60f76119188a2470"}],"tree":"d7d4a94c700dc0e84ee943019213d2358a49c413","message":"fix deprecation warnings","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-05-29T07:16:28-07:00","committed_date":"2012-05-29T07:16:28-07:00"}}]
+0
-38
spec/fixtures/build.json less more
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "Administrator",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2015-12-24T15:51:21.880Z",
12 "download_url": null,
13 "finished_at": "2015-12-24T17:54:31.198Z",
14 "id": 8,
15 "name": "rubocop",
16 "ref": "master",
17 "runner": null,
18 "stage": "test",
19 "started_at": "2015-12-24T17:54:30.733Z",
20 "status": "failed",
21 "tag": false,
22 "user": {
23 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
24 "bio": null,
25 "created_at": "2015-12-21T13:14:24.077Z",
26 "id": 1,
27 "is_admin": true,
28 "linkedin": "",
29 "name": "John Smith",
30 "skype": "",
31 "state": "active",
32 "twitter": "",
33 "username": "root",
34 "web_url": "http://gitlab.dev/u/root",
35 "website_url": ""
36 }
37 }
spec/fixtures/build_artifacts.json less more
Binary diff not shown
+0
-24
spec/fixtures/build_cancel.json less more
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "John Smith",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2016-01-11T10:13:33.506Z",
12 "download_url": null,
13 "finished_at": "2016-01-11T10:14:09.526Z",
14 "id": 69,
15 "name": "rubocop",
16 "ref": "master",
17 "runner": null,
18 "stage": "test",
19 "started_at": null,
20 "status": "canceled",
21 "tag": false,
22 "user": null
23 }
+0
-24
spec/fixtures/build_erase.json less more
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "John Smith",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "download_url": null,
12 "id": 69,
13 "name": "rubocop",
14 "ref": "master",
15 "runner": null,
16 "stage": "test",
17 "created_at": "2016-01-11T10:13:33.506Z",
18 "started_at": "2016-01-11T10:13:33.506Z",
19 "finished_at": "2016-01-11T10:15:10.506Z",
20 "status": "failed",
21 "tag": false,
22 "user": null
23 }
+0
-24
spec/fixtures/build_retry.json less more
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "John Smith",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2016-01-11T10:13:33.506Z",
12 "download_url": null,
13 "finished_at": null,
14 "id": 69,
15 "name": "rubocop",
16 "ref": "master",
17 "runner": null,
18 "stage": "test",
19 "started_at": null,
20 "status": "pending",
21 "tag": false,
22 "user": null
23 }
+0
-78
spec/fixtures/builds.json less more
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2015-12-24T15:51:21.802Z",
13 "download_url": null,
14 "finished_at": "2015-12-24T17:54:27.895Z",
15 "id": 7,
16 "name": "teaspoon",
17 "ref": "master",
18 "runner": null,
19 "stage": "test",
20 "started_at": "2015-12-24T17:54:27.722Z",
21 "status": "failed",
22 "tag": false,
23 "user": {
24 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
25 "bio": null,
26 "created_at": "2015-12-21T13:14:24.077Z",
27 "id": 1,
28 "is_admin": true,
29 "linkedin": "",
30 "name": "Administrator",
31 "skype": "",
32 "state": "active",
33 "twitter": "",
34 "username": "root",
35 "web_url": "http://gitlab.dev/u/root",
36 "website_url": ""
37 }
38 },
39 {
40 "commit": {
41 "author_email": "admin@example.com",
42 "author_name": "Administrator",
43 "created_at": "2015-12-24T16:51:14.000+01:00",
44 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
45 "message": "Test the CI integration.",
46 "short_id": "0ff3ae19",
47 "title": "Test the CI integration."
48 },
49 "coverage": null,
50 "created_at": "2015-12-24T15:51:21.727Z",
51 "download_url": null,
52 "finished_at": "2015-12-24T17:54:24.921Z",
53 "id": 6,
54 "name": "spinach:other",
55 "ref": "master",
56 "runner": null,
57 "stage": "test",
58 "started_at": "2015-12-24T17:54:24.729Z",
59 "status": "failed",
60 "tag": false,
61 "user": {
62 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
63 "bio": null,
64 "created_at": "2015-12-21T13:14:24.077Z",
65 "id": 1,
66 "is_admin": true,
67 "linkedin": "",
68 "name": "Administrator",
69 "skype": "",
70 "state": "active",
71 "twitter": "",
72 "username": "root",
73 "web_url": "http://gitlab.dev/u/root",
74 "website_url": ""
75 }
76 }
77 ]
+0
-64
spec/fixtures/builds_commits.json less more
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2016-01-11T10:13:33.506Z",
13 "download_url": null,
14 "finished_at": "2016-01-11T10:14:09.526Z",
15 "id": 69,
16 "name": "rubocop",
17 "ref": "master",
18 "runner": null,
19 "stage": "test",
20 "started_at": null,
21 "status": "canceled",
22 "tag": false,
23 "user": null
24 },
25 {
26 "commit": {
27 "author_email": "admin@example.com",
28 "author_name": "Administrator",
29 "created_at": "2015-12-24T16:51:14.000+01:00",
30 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
31 "message": "Test the CI integration.",
32 "short_id": "0ff3ae19",
33 "title": "Test the CI integration."
34 },
35 "coverage": null,
36 "created_at": "2015-12-24T15:51:21.957Z",
37 "download_url": null,
38 "finished_at": "2015-12-24T17:54:33.913Z",
39 "id": 9,
40 "name": "brakeman",
41 "ref": "master",
42 "runner": null,
43 "stage": "test",
44 "started_at": "2015-12-24T17:54:33.727Z",
45 "status": "failed",
46 "tag": false,
47 "user": {
48 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
49 "bio": null,
50 "created_at": "2015-12-21T13:14:24.077Z",
51 "id": 1,
52 "is_admin": true,
53 "linkedin": "",
54 "name": "Administrator",
55 "skype": "",
56 "state": "active",
57 "twitter": "",
58 "username": "root",
59 "web_url": "http://gitlab.dev/u/root",
60 "website_url": ""
61 }
62 }
63 ]
+0
-31
spec/fixtures/compare_merge_request_diff.json less more
0
1 {
2 "commit": {
3 "id": "12d65c8dd2b2676fa3ac47d955accc085a37a9c1",
4 "short_id": "12d65c8dd2b",
5 "title": "JS fix",
6 "author_name": "Dmitriy Zaporozhets",
7 "author_email": "dmitriy.zaporozhets@gmail.com",
8 "created_at": "2014-02-27T10:27:00+02:00"
9 },
10 "commits": [{
11 "id": "12d65c8dd2b2676fa3ac47d955accc085a37a9c1",
12 "short_id": "12d65c8dd2b",
13 "title": "JS fix",
14 "author_name": "Dmitriy Zaporozhets",
15 "author_email": "dmitriy.zaporozhets@gmail.com",
16 "created_at": "2014-02-27T10:27:00+02:00"
17 }],
18 "diffs": [{
19 "old_path": "files/js/application.js",
20 "new_path": "files/js/application.js",
21 "a_mode": null,
22 "b_mode": "100644",
23 "diff": "--- a/files/js/application.js\n+++ b/files/js/application.js\n@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}",
24 "new_file": false,
25 "renamed_file": false,
26 "deleted_file": false
27 }],
28 "compare_timeout": false,
29 "compare_same_ref": false
30 }
+0
-0
spec/fixtures/empty.json less more
(Empty file)
+0
-6
spec/fixtures/environment.json less more
0 {
1 "id": 12,
2 "name": "staging",
3 "slug": "staging-cb247rv",
4 "external_url": "https://staging.example.gitlab.com"
5 }
+0
-14
spec/fixtures/environments.json less more
0 [
1 {
2 "id": 1,
3 "name": "review/fix-foo",
4 "slug": "review-fix-foo-dfjre3",
5 "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com"
6 },
7 {
8 "id": 12,
9 "name": "review/fix-bar",
10 "slug": "review-fix-bar-dbwr18",
11 "external_url": "https://review-fix-bar-dbwr18.example.gitlab.com"
12 }
13 ]
+0
-1
spec/fixtures/error_already_exists.json less more
0 {"message": "409 Already exists"}
+0
-1
spec/fixtures/error_project_not_found.json less more
0 {"message": "404 Project Not Found"}
+0
-1
spec/fixtures/get_repository_file.json less more
0 {"file_name":"README.md", "file_path":"README.md", "size":"19", "encoding":"base64", "content":"VGhpcyBpcyBhICpSRUFETUUqIQ==\n", "ref":"master", "blob_id":"0eba9dff767611060181e0423a1de2941d27efc8", "commit_id":"eb38397cb6ae669219e6bc18ad19981fff18ea29"}
+0
-60
spec/fixtures/group.json less more
0 {"id": 10, "name": "GitLab-Group", "path": "gitlab-group", "owner_id": 6, "projects": [
1 {
2 "id": 9,
3 "name": "mojito",
4 "description": null,
5 "default_branch": "master",
6 "owner": {
7 "id": 6,
8 "username": "jose",
9 "email": "jose@abc.com",
10 "name": "Jose Jose",
11 "blocked": false,
12 "created_at": "2013-02-06T06:54:06Z"
13 },
14 "path": "mojito",
15 "path_with_namespace": "gitlab-group/mojito",
16 "issues_enabled": true,
17 "merge_requests_enabled": true,
18 "wall_enabled": true,
19 "wiki_enabled": true,
20 "created_at": "2013-02-06T16:59:15Z",
21 "namespace": {
22 "created_at": "2013-02-06T16:58:22Z",
23 "id": 10,
24 "name": "GitLab-Group",
25 "owner_id": 6,
26 "path": "gitlab-group",
27 "updated_at": "2013-02-06T16:58:22Z"
28 }
29 },
30 {
31 "id": 10,
32 "name": "gitlabhq",
33 "description": null,
34 "default_branch": null,
35 "owner": {
36 "id": 6,
37 "username": "randx",
38 "email": "randx@github.com",
39 "name": "Dmitry Z",
40 "blocked": false,
41 "created_at": "2013-02-06T06:54:06Z"
42 },
43 "path": "gitlabhq",
44 "path_with_namespace": "gitlab-group/gitlabhq",
45 "issues_enabled": true,
46 "merge_requests_enabled": true,
47 "wall_enabled": true,
48 "wiki_enabled": true,
49 "created_at": "2013-02-06T17:02:31Z",
50 "namespace": {
51 "created_at": "2013-02-06T16:58:22Z",
52 "id": 10,
53 "name": "GitLab-Group",
54 "owner_id": 6,
55 "path": "gitlab-group",
56 "updated_at": "2013-02-06T16:58:22Z"
57 }
58 }
59 ]}
+0
-1
spec/fixtures/group_create.json less more
0 {"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1}
+0
-1
spec/fixtures/group_create_with_description.json less more
0 {"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1,"description":"gitlab group description"}
+0
-1
spec/fixtures/group_delete.json less more
0 {"id":42,"name":"Gitlab-Group","path":"gitlab-group","created_at":"2016-02-24T20:16:42.906Z","updated_at":"2016-02-24T20:16:42.906Z"}
+0
-1
spec/fixtures/group_member.json less more
0 {"id":2,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-09-04T18:15:30Z","access_level":10}
+0
-1
spec/fixtures/group_member_delete.json less more
0 {"created_at":"2013-09-04T18:18:15Z","group_access":10,"group_id":3,"id":2,"notification_level":3,"updated_at":"2013-09-04T18:18:15Z","user_id":2}
+0
-1
spec/fixtures/group_member_edit.json less more
0 {"id":2,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-09-04T18:15:30Z","access_level":50}
+0
-1
spec/fixtures/group_members.json less more
0 [{"id":1,"username":"eraymond","email":"eraymond@local.host","name":"Edward Raymond","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50},{"id":1,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50}]
+0
-44
spec/fixtures/group_projects.json less more
0 [
1 {
2 "id": 4,
3 "description": null,
4 "default_branch": "master",
5 "public": false,
6 "visibility_level": 0,
7 "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git",
8 "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git",
9 "web_url": "http://example.com/diaspora/diaspora-client",
10 "tag_list": [
11 "example",
12 "disapora client"
13 ],
14 "owner": {
15 "id": 3,
16 "name": "Diaspora",
17 "created_at": "2013-09-30T13: 46: 02Z"
18 },
19 "name": "Diaspora Client",
20 "name_with_namespace": "Diaspora / Diaspora Client",
21 "path": "diaspora-client",
22 "path_with_namespace": "diaspora/diaspora-client",
23 "issues_enabled": true,
24 "merge_requests_enabled": true,
25 "builds_enabled": true,
26 "wiki_enabled": true,
27 "snippets_enabled": false,
28 "created_at": "2013-09-30T13: 46: 02Z",
29 "last_activity_at": "2013-09-30T13: 46: 02Z",
30 "creator_id": 3,
31 "namespace": {
32 "created_at": "2013-09-30T13: 46: 02Z",
33 "description": "",
34 "id": 3,
35 "name": "Diaspora",
36 "owner_id": 1,
37 "path": "diaspora",
38 "updated_at": "2013-09-30T13: 46: 02Z"
39 },
40 "archived": false,
41 "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png"
42 }
43 ]
+0
-2
spec/fixtures/group_search.json less more
0 [{"id": 5,"name": "Five-Group","path": "five-group","owner_id": 2},{"id": 8,"name": "Eight Group","path": "eight-group","owner_id": 6}
1 ]
+0
-2
spec/fixtures/groups.json less more
0 [{"id": 3,"name": "ThreeGroup","path": "threegroup","owner_id": 1},{"id": 5,"name": "Five-Group","path": "five-group","owner_id": 2},{"id": 8,"name": "Eight Group","path": "eight-group","owner_id": 6}
1 ]
+0
-1
spec/fixtures/issue.json less more
0 {"id":33,"project_id":3,"title":"Beatae possimus nostrum nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}
+0
-16
spec/fixtures/issue_award_emoji.json less more
0 {
1 "id": 4,
2 "name": "blowfish",
3 "user": {
4 "name": "Administrator",
5 "username": "root",
6 "id": 1,
7 "state": "active",
8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
9 "web_url": "http://gitlab.example.com/root"
10 },
11 "created_at": "2016-06-15T10:09:34.206Z",
12 "updated_at": "2016-06-15T10:09:34.206Z",
13 "awardable_id": 80,
14 "awardable_type": "Issue"
15 }
+0
-34
spec/fixtures/issue_award_emojis.json less more
0 [
1 {
2 "id": 4,
3 "name": "1234",
4 "user": {
5 "name": "Administrator",
6 "username": "root",
7 "id": 1,
8 "state": "active",
9 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
10 "web_url": "http://gitlab.example.com/root"
11 },
12 "created_at": "2016-06-15T10:09:34.206Z",
13 "updated_at": "2016-06-15T10:09:34.206Z",
14 "awardable_id": 80,
15 "awardable_type": "Issue"
16 },
17 {
18 "id": 1,
19 "name": "microphone",
20 "user": {
21 "name": "User 4",
22 "username": "user4",
23 "id": 26,
24 "state": "active",
25 "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
26 "web_url": "http://gitlab.example.com/user4"
27 },
28 "created_at": "2016-06-15T10:09:34.177Z",
29 "updated_at": "2016-06-15T10:09:34.177Z",
30 "awardable_id": 80,
31 "awardable_type": "Issue"
32 }
33 ]
+0
-1
spec/fixtures/issues.json less more
0 [{"id":1,"project_id":1,"title":"Culpa eius recusandae suscipit autem distinctio dolorum.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":6,"project_id":2,"title":"Ut in dolorum omnis sed sit aliquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":21,"project_id":1,"title":"Vitae ea aliquam et quo eligendi sapiente voluptatum labore hic nihil culpa.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":26,"project_id":2,"title":"Quo enim est nihil atque placeat voluptas neque eos voluptas.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]
+0
-43
spec/fixtures/job.json less more
0 {
1 "commit": {
2 "author_email": "admin@example.com",
3 "author_name": "Administrator",
4 "created_at": "2015-12-24T16:51:14.000+01:00",
5 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
6 "message": "Test the CI integration.",
7 "short_id": "0ff3ae19",
8 "title": "Test the CI integration."
9 },
10 "coverage": null,
11 "created_at": "2015-12-24T15:51:21.880Z",
12 "artifacts_file": null,
13 "finished_at": "2015-12-24T17:54:31.198Z",
14 "id": 8,
15 "name": "rubocop",
16 "pipeline": {
17 "id": 6,
18 "ref": "master",
19 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
20 "status": "pending"
21 },
22 "ref": "master",
23 "runner": null,
24 "stage": "test",
25 "started_at": "2015-12-24T17:54:30.733Z",
26 "status": "failed",
27 "tag": false,
28 "user": {
29 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
30 "bio": null,
31 "created_at": "2015-12-21T13:14:24.077Z",
32 "id": 1,
33 "linkedin": "",
34 "name": "Administrator",
35 "skype": "",
36 "state": "active",
37 "twitter": "",
38 "username": "root",
39 "web_url": "http://gitlab.dev/root",
40 "website_url": ""
41 }
42 }
+0
-1
spec/fixtures/job_trace.json less more
0 asdasd
+0
-91
spec/fixtures/jobs.json less more
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2015-12-24T15:51:21.802Z",
13 "artifacts_file": {
14 "filename": "artifacts.zip",
15 "size": 1000
16 },
17 "finished_at": "2015-12-24T17:54:27.895Z",
18 "id": 7,
19 "name": "teaspoon",
20 "pipeline": {
21 "id": 6,
22 "ref": "master",
23 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
24 "status": "pending"
25 },
26 "ref": "master",
27 "runner": null,
28 "stage": "test",
29 "started_at": "2015-12-24T17:54:27.722Z",
30 "status": "failed",
31 "tag": false,
32 "user": {
33 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
34 "bio": null,
35 "created_at": "2015-12-21T13:14:24.077Z",
36 "id": 1,
37 "linkedin": "",
38 "name": "Administrator",
39 "skype": "",
40 "state": "active",
41 "twitter": "",
42 "username": "root",
43 "web_url": "http://gitlab.dev/root",
44 "website_url": ""
45 }
46 },
47 {
48 "commit": {
49 "author_email": "admin@example.com",
50 "author_name": "Administrator",
51 "created_at": "2015-12-24T16:51:14.000+01:00",
52 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
53 "message": "Test the CI integration.",
54 "short_id": "0ff3ae19",
55 "title": "Test the CI integration."
56 },
57 "coverage": null,
58 "created_at": "2015-12-24T15:51:21.727Z",
59 "artifacts_file": null,
60 "finished_at": "2015-12-24T17:54:24.921Z",
61 "id": 6,
62 "name": "spinach:other",
63 "pipeline": {
64 "id": 6,
65 "ref": "master",
66 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
67 "status": "pending"
68 },
69 "ref": "master",
70 "runner": null,
71 "stage": "test",
72 "started_at": "2015-12-24T17:54:24.729Z",
73 "status": "failed",
74 "tag": false,
75 "user": {
76 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
77 "bio": null,
78 "created_at": "2015-12-21T13:14:24.077Z",
79 "id": 1,
80 "linkedin": "",
81 "name": "Administrator",
82 "skype": "",
83 "state": "active",
84 "twitter": "",
85 "username": "root",
86 "web_url": "http://gitlab.dev/root",
87 "website_url": ""
88 }
89 }
90 ]
+0
-1
spec/fixtures/key.json less more
0 {"id":1,"title":"narkoz@helium","key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkUsh42Nh1yefGd1jbSELn5XsY8p5Oxmau0/1HqHnjuYOaj5X+kHccFDwtmtg9Ox8ua/+WptNsiE8IUwsD3zKgEjajgwq3gMeeFdxfXwM+tEvHOOMV9meRrgRWGYCToPbT6sR7/YMAYa7cPqWSpx/oZhYfz4XtoMv3ZZT1fZMmx3MY3HwXwW8j+obJyN2K4LN0TFi9RPgWWYn0DCyb9OccmABimt3i74WoJ/OT8r6/7swce8+OSe0Q2wBhyTtvxg2vtUcoek8Af+EZaUMBwSEzEsocOCzwQvjF5XUk5o7dJ8nP8W3RE60JWX57t16eQm7lBmumLYfszpn2isd6W7a1 narkoz@helium"}
+0
-1
spec/fixtures/keys.json less more
0 [{"id":1,"title":"narkoz@helium","key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkUsh42Nh1yefGd1jbSELn5XsY8p5Oxmau0/1HqHnjuYOaj5X+kHccFDwtmtg9Ox8ua/+WptNsiE8IUwsD3zKgEjajgwq3gMeeFdxfXwM+tEvHOOMV9meRrgRWGYCToPbT6sR7/YMAYa7cPqWSpx/oZhYfz4XtoMv3ZZT1fZMmx3MY3HwXwW8j+obJyN2K4LN0TFi9RPgWWYn0DCyb9OccmABimt3i74WoJ/OT8r6/7swce8+OSe0Q2wBhyTtvxg2vtUcoek8Af+EZaUMBwSEzEsocOCzwQvjF5XUk5o7dJ8nP8W3RE60JWX57t16eQm7lBmumLYfszpn2isd6W7a1 narkoz@helium"}]
+0
-1
spec/fixtures/label.json less more
0 {"name": "Backlog", "color": "#DD10AA", "subscribed": true}
+0
-1
spec/fixtures/label_unsubscribe.json less more
0 {"name": "Backlog", "color": "#DD10AA", "subscribed": false}
+0
-1
spec/fixtures/labels.json less more
0 [{"name": "Backlog", "color": "#DD10AA"},{"name": "Documentation", "color": "#1E80DD"}]
+0
-1
spec/fixtures/merge_request.json less more
0 {"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}
+0
-16
spec/fixtures/merge_request_award_emoji.json less more
0 {
1 "id": 4,
2 "name": "blowfish",
3 "user": {
4 "name": "Administrator",
5 "username": "root",
6 "id": 1,
7 "state": "active",
8 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
9 "web_url": "http://gitlab.example.com/root"
10 },
11 "created_at": "2016-06-15T10:09:34.206Z",
12 "updated_at": "2016-06-15T10:09:34.206Z",
13 "awardable_id": 80,
14 "awardable_type": "MergeRequest"
15 }
+0
-34
spec/fixtures/merge_request_award_emojis.json less more
0 [
1 {
2 "id": 4,
3 "name": "1234",
4 "user": {
5 "name": "Administrator",
6 "username": "root",
7 "id": 1,
8 "state": "active",
9 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
10 "web_url": "http://gitlab.example.com/root"
11 },
12 "created_at": "2016-06-15T10:09:34.206Z",
13 "updated_at": "2016-06-15T10:09:34.206Z",
14 "awardable_id": 80,
15 "awardable_type": "MergeRequest"
16 },
17 {
18 "id": 1,
19 "name": "microphone",
20 "user": {
21 "name": "User 4",
22 "username": "user4",
23 "id": 26,
24 "state": "active",
25 "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
26 "web_url": "http://gitlab.example.com/user4"
27 },
28 "created_at": "2016-06-15T10:09:34.177Z",
29 "updated_at": "2016-06-15T10:09:34.177Z",
30 "awardable_id": 80,
31 "awardable_type": "MergeRequest"
32 }
33 ]
+0
-1
spec/fixtures/merge_request_changes.json less more
0 {"id":2,"iid":5,"project_id":3,"title":"Uncovered","description":"","state":"opened","created_at":"2015-03-15T23:15:13.292+01:00","updated_at":"2015-03-15T23:15:14.132+01:00","target_branch":"master","source_branch":"uncovered","upvotes":0,"downvotes":0,"author":{"name":"Dominik Sander","username":"dsander","id":1,"state":"active","avatar_url":"https://secure.gravatar.com/avatar/7f01734389dd6730d076ddee04838bd3?s=40\u0026d=identicon"},"assignee":null,"source_project_id":6,"target_project_id":6,"labels":[],"milestone":null,"changes":[{"old_path":"lib/omniauth/builder.rb","new_path":"lib/omniauth/builder.rb","a_mode":"100644","b_mode":"100644","diff":"--- a/lib/omniauth/builder.rb\n+++ b/lib/omniauth/builder.rb\n@@ -7,11 +7,13 @@ module OmniAuth\n else\n @app = app\n super(\u0026block)\n+ two = 1 # woah! uncovered\n @ins \u003c\u003c @app\n end\n end\n \n def rack14?\n+ one = 2 # thats oke!\n Rack.release.split('.')[1].to_i \u003e= 4\n end\n ","new_file":false,"renamed_file":false,"deleted_file":false}]}
+0
-1
spec/fixtures/merge_request_closes_issues.json less more
0 [{"id":1,"iid":1,"project_id":5,"title":"Merge request 1 issue 1","description":"","state":"opened","created_at":"2017-04-06T08:03:36.163Z","updated_at":"2017-04-06T08:03:57.087Z","labels":[],"milestone":null,"assignee":null,"author":{"name":"John","username":"jdoe","id":1,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoe"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/issues/1"},{"id":2,"iid":2,"project_id":5,"title":"Merge request 1 issue 2","description":"","state":"opened","created_at":"2017-04-06T08:03:44.023Z","updated_at":"2017-04-06T08:03:44.023Z","labels":[],"milestone":null,"assignee":null,"author":{"name":"John","username":"jdoe","id":426047,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoe"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/issues/2"}]
+0
-1
spec/fixtures/merge_request_comment.json less more
0 {"note":"Cool Merge Request!","author":{"id":1,"username":"jsmith","email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-07-11T01:32:18Z"}}
+0
-1
spec/fixtures/merge_request_comments.json less more
0 [{"note":"this is the 1st comment on the 2merge merge request","author":{"id":11,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}},{"note":"another discussion point on the 2merge request","author":{"id":12,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}}]
+0
-1
spec/fixtures/merge_request_commits.json less more
0 [{"id":"a2da7552f26d5b46a6a09bb8b7b066e3a102be7d","short_id":"a2da7552","title": "piyo","author_name":"example","author_email":"example@example.com","created_at":"2015-12-19T18:02:31.000+09:00","message":"fuga"},{"id":"3ce509590f37dbce5b877c3e1c78bd3903493170","short_id":"3ce50959","title":"hoge","author_name":"example","author_email":"example@example.com","created_at":"2015-12-19T17:53:46.000+09:00","message":"Hoge"}]
+0
-1
spec/fixtures/merge_requests.json less more
0 [{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}]
+0
-1
spec/fixtures/milestone.json less more
0 {"id":1,"project_id":3,"title":"3.0","description":"","due_date":"2012-10-22","closed":false,"updated_at":"2012-09-17T10:15:31Z","created_at":"2012-09-17T10:15:31Z"}
+0
-1
spec/fixtures/milestone_issues.json less more
0 [{"id":1,"project_id":3,"title":"Culpa eius recusandae suscipit autem distinctio dolorum.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":6,"project_id":3,"title":"Ut in dolorum omnis sed sit aliquam.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":21,"project_id":3,"title":"Vitae ea aliquam et quo eligendi sapiente voluptatum labore hic nihil culpa.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":26,"project_id":3,"title":"Quo enim est nihil atque placeat voluptas neque eos voluptas.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]
+0
-1
spec/fixtures/milestone_merge_requests.json less more
0 [{"id":1,"iid":1,"project_id":1,"title":"lorem ipsum","description":"","state":"opened","created_at":"2017-03-24T12:23:53.918Z","updated_at":"2017-03-24T12:23:53.918Z","target_branch":"master","source_branch":"def","upvotes":0,"downvotes":0,"author":{"name":"John Doe","username":"jdoe","id":1,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoen"},"assignee":null,"source_project_id":1,"target_project_id":1,"labels":[],"work_in_progress":false,"milestone":{"id":1,"iid":1,"project_id":1,"title":"Test","description":"","state":"active","created_at":"2017-03-24T12:23:00.560Z","updated_at":"2017-03-24T12:23:00.560Z","due_date":null,"start_date":null},"merge_when_pipeline_succeeds":false,"merge_status":"can_be_merged","sha":"aec123d1775790b2347fdd684b5ba613fdeb994b","merge_commit_sha":null,"user_notes_count":0,"approvals_before_merge":null,"should_remove_source_branch":null,"force_remove_source_branch":false,"squash":false,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/merge_requests/2"},{"id":2,"iid":2,"project_id":1,"title":"ipsum lorem","description":"","state":"opened","created_at":"2017-03-24T12:23:24.662Z","updated_at":"2017-03-24T12:23:33.522Z","target_branch":"master","source_branch":"test1","upvotes":0,"downvotes":0,"author":{"name":"Joren","username":"jdoe","id":1,"state":"active","":"","web_url":"https://gitlab.com/jdoe"},"assignee":null,"source_project_id":1,"target_project_id":1,"labels":[],"work_in_progress":false,"milestone":{"id":1,"iid":1,"project_id":1,"title":"Test","description":"","state":"active","created_at":"2017-03-24T12:23:00.560Z","updated_at":"2017-03-24T12:23:00.560Z","due_date":null,"start_date":null},"merge_when_pipeline_succeeds":false,"merge_status":"can_be_merged","sha":"3ee44c9b40deddae596f838b97523c6f010fd80d","merge_commit_sha":null,"user_notes_count":0,"approvals_before_merge":null,"should_remove_source_branch":null,"force_remove_source_branch":true,"squash":false,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/merge_requests/1"}]
+0
-1
spec/fixtures/milestones.json less more
0 [{"id":1,"project_id":3,"title":"3.0","description":"","due_date":"2012-10-22","closed":false,"updated_at":"2012-09-17T10:15:31Z","created_at":"2012-09-17T10:15:31Z"}]
+0
-1
spec/fixtures/namespaces.json less more
0 [{"id": 1, "path": "john", "kind": "user"}]
+0
-1
spec/fixtures/note.json less more
0 {"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"}
+0
-16
spec/fixtures/note_award_emoji.json less more
0 {
1 "id": 4,
2 "name": "mood_bubble_lightning",
3 "user": {
4 "name": "User 4",
5 "username": "user4",
6 "id": 26,
7 "state": "active",
8 "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
9 "web_url": "http://gitlab.example.com/user4"
10 },
11 "created_at": "2016-06-15T10:09:34.197Z",
12 "updated_at": "2016-06-15T10:09:34.197Z",
13 "awardable_id": 1,
14 "awardable_type": "Note"
15 }
+0
-18
spec/fixtures/note_award_emojis.json less more
0 [
1 {
2 "id": 2,
3 "name": "mood_bubble_lightning",
4 "user": {
5 "name": "User 4",
6 "username": "user4",
7 "id": 26,
8 "state": "active",
9 "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon",
10 "web_url": "http://gitlab.example.com/user4"
11 },
12 "created_at": "2016-06-15T10:09:34.197Z",
13 "updated_at": "2016-06-15T10:09:34.197Z",
14 "awardable_id": 1,
15 "awardable_type": "Note"
16 }
17 ]
+0
-1
spec/fixtures/notes.json less more
0 [{"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"},{"id":1207,"body":"I know, right?","author":{"id":1,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"created_at":"2012-11-27T19:58:21Z"}]
+0
-23
spec/fixtures/pipeline.json less more
0 {
1 "id": 46,
2 "status": "success",
3 "ref": "master",
4 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
5 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-08-11T11:28:34.085Z",
17 "updated_at": "2016-08-11T11:32:35.169Z",
18 "started_at": null,
19 "finished_at": "2016-08-11T11:32:35.145Z",
20 "committed_at": null,
21 "duration": null
22 }
+0
-23
spec/fixtures/pipeline_cancel.json less more
0 {
1 "id": 46,
2 "status": "canceled",
3 "ref": "master",
4 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
5 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-08-11T11:28:34.085Z",
17 "updated_at": "2016-08-11T11:32:35.169Z",
18 "started_at": null,
19 "finished_at": "2016-08-11T11:32:35.145Z",
20 "committed_at": null,
21 "duration": null
22 }
+0
-23
spec/fixtures/pipeline_create.json less more
0 {
1 "id": 61,
2 "sha": "384c444e840a515b23f21915ee5766b87068a70d",
3 "ref": "master",
4 "status": "pending",
5 "before_sha": "0000000000000000000000000000000000000000",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-11-04T09:36:13.747Z",
17 "updated_at": "2016-11-04T09:36:13.977Z",
18 "started_at": null,
19 "finished_at": null,
20 "committed_at": null,
21 "duration": null
22 }
+0
-91
spec/fixtures/pipeline_jobs.json less more
0 [
1 {
2 "commit": {
3 "author_email": "admin@example.com",
4 "author_name": "Administrator",
5 "created_at": "2015-12-24T16:51:14.000+01:00",
6 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7 "message": "Test the CI integration.",
8 "short_id": "0ff3ae19",
9 "title": "Test the CI integration."
10 },
11 "coverage": null,
12 "created_at": "2015-12-24T15:51:21.802Z",
13 "artifacts_file": {
14 "filename": "artifacts.zip",
15 "size": 1000
16 },
17 "finished_at": "2015-12-24T17:54:27.895Z",
18 "id": 7,
19 "name": "teaspoon",
20 "pipeline": {
21 "id": 6,
22 "ref": "master",
23 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
24 "status": "pending"
25 },
26 "ref": "master",
27 "runner": null,
28 "stage": "test",
29 "started_at": "2015-12-24T17:54:27.722Z",
30 "status": "failed",
31 "tag": false,
32 "user": {
33 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
34 "bio": null,
35 "created_at": "2015-12-21T13:14:24.077Z",
36 "id": 1,
37 "linkedin": "",
38 "name": "Administrator",
39 "skype": "",
40 "state": "active",
41 "twitter": "",
42 "username": "root",
43 "web_url": "http://gitlab.dev/root",
44 "website_url": ""
45 }
46 },
47 {
48 "commit": {
49 "author_email": "admin@example.com",
50 "author_name": "Administrator",
51 "created_at": "2015-12-24T16:51:14.000+01:00",
52 "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
53 "message": "Test the CI integration.",
54 "short_id": "0ff3ae19",
55 "title": "Test the CI integration."
56 },
57 "coverage": null,
58 "created_at": "2015-12-24T15:51:21.727Z",
59 "artifacts_file": null,
60 "finished_at": "2015-12-24T17:54:24.921Z",
61 "id": 6,
62 "name": "spinach:other",
63 "pipeline": {
64 "id": 6,
65 "ref": "master",
66 "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
67 "status": "pending"
68 },
69 "ref": "master",
70 "runner": null,
71 "stage": "test",
72 "started_at": "2015-12-24T17:54:24.729Z",
73 "status": "failed",
74 "tag": false,
75 "user": {
76 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
77 "bio": null,
78 "created_at": "2015-12-21T13:14:24.077Z",
79 "id": 1,
80 "linkedin": "",
81 "name": "Administrator",
82 "skype": "",
83 "state": "active",
84 "twitter": "",
85 "username": "root",
86 "web_url": "http://gitlab.dev/root",
87 "website_url": ""
88 }
89 }
90 ]
+0
-23
spec/fixtures/pipeline_retry.json less more
0 {
1 "id": 46,
2 "status": "pending",
3 "ref": "master",
4 "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
5 "before_sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
6 "tag": false,
7 "yaml_errors": null,
8 "user": {
9 "name": "Administrator",
10 "username": "root",
11 "id": 1,
12 "state": "active",
13 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
14 "web_url": "http://localhost:3000/root"
15 },
16 "created_at": "2016-08-11T11:28:34.085Z",
17 "updated_at": "2016-08-11T11:32:35.169Z",
18 "started_at": null,
19 "finished_at": "2016-08-11T11:32:35.145Z",
20