Skip to content

Commit 03f869b

Browse files
author
morinluc0
authored
Merge branch 'master' into 355-wiki-support
2 parents 379f63f + 5918788 commit 03f869b

32 files changed

+1324
-381
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
language: php
22

3-
sudo: false
4-
53
php:
64
- 5.6
75
- 7.0
86
- 7.1
97
- 7.2
108
- 7.3
9+
- 7.4
1110

1211
matrix:
1312
# test latest PHP stable version with lowest dependencies and phpstan static analysis
1413
include:
15-
- php: 7.1
16-
env: COMPOSER_FLAGS="--prefer-lowest" STATIC_ANALYSIS=yes
14+
- php: 7.3
15+
env: STATIC_ANALYSIS=yes
1716

1817
before_script:
1918
- travis_retry composer self-update

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
"require": {
2424
"php": "^5.6 || ^7.0",
2525
"ext-xml": "*",
26-
"php-http/client-common": "^1.6",
26+
"php-http/client-common": "^1.6 || ^2.0",
2727
"php-http/client-implementation": "^1.0",
2828
"php-http/discovery": "^1.2",
29-
"php-http/httplug": "^1.1",
29+
"php-http/httplug": "^1.1 || ^2.0",
3030
"php-http/multipart-stream-builder": "^1.0",
31-
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
31+
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0 || ^5.0"
3232
},
3333
"require-dev": {
3434
"guzzlehttp/psr7": "^1.2",
35-
"php-http/guzzle6-adapter": "^1.0",
36-
"php-http/mock-client": "^1.0",
37-
"phpunit/phpunit": "^5.7.27 || ^6.5"
35+
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
36+
"php-http/mock-client": "^1.2",
37+
"phpunit/phpunit": "^5.7.27 || ^7.5.15"
3838
},
3939
"autoload": {
4040
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
@@ -44,7 +44,7 @@
4444
},
4545
"extra": {
4646
"branch-alias": {
47-
"dev-master": "9.12.x-dev"
47+
"dev-master": "9.16-dev"
4848
}
4949
}
5050
}

lib/Gitlab/Api/Environments.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,14 @@ public function stop($project_id, $environment_id)
5555
{
5656
return $this->post($this->getProjectPath($project_id, 'environments/'.$this->encodePath($environment_id).'/stop'));
5757
}
58+
59+
/**
60+
* @param int $project_id
61+
* @param string $environment_id
62+
* @return mixed
63+
*/
64+
public function show($project_id, $environment_id)
65+
{
66+
return $this->get($this->getProjectPath($project_id, 'environments/' . $this->encodePath($environment_id)));
67+
}
5868
}

lib/Gitlab/Api/Groups.php

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,20 @@ public function removeMember($group_id, $user_id)
160160
* @param $id
161161
* @param array $parameters (
162162
*
163-
* @var bool $archived Limit by archived status.
164-
* @var string $visibility Limit by visibility public, internal, or private.
165-
* @var string $order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
166-
* Default is created_at.
167-
* @var string $sort Return projects sorted in asc or desc order. Default is desc.
168-
* @var string $search Return list of authorized projects matching the search criteria.
169-
* @var bool $simple Return only the ID, URL, name, and path of each project.
170-
* @var bool $owned Limit by projects owned by the current user.
171-
* @var bool $starred Limit by projects starred by the current user.
163+
* @var bool $archived Limit by archived status.
164+
* @var string $visibility Limit by visibility public, internal, or private.
165+
* @var string $order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
166+
* Default is created_at.
167+
* @var string $sort Return projects sorted in asc or desc order. Default is desc.
168+
* @var string $search Return list of authorized projects matching the search criteria.
169+
* @var bool $simple Return only the ID, URL, name, and path of each project.
170+
* @var bool $owned Limit by projects owned by the current user.
171+
* @var bool $starred Limit by projects starred by the current user.
172+
* @var bool $with_issues_enabled Limit by projects with issues feature enabled. Default is false.
173+
* @var bool $with_merge_requests_enabled Limit by projects with merge requests feature enabled. Default is false.
174+
* @var bool $with_shared Include projects shared to this group. Default is true.
175+
* @var bool $include_subgroups Include projects in subgroups of this group. Default is false.
176+
* @var bool $with_custom_attributes Include custom attributes in response (admins only).
172177
* )
173178
*
174179
* @return mixed
@@ -206,6 +211,26 @@ public function projects($id, array $parameters = [])
206211
->setAllowedTypes('starred', 'bool')
207212
->setNormalizer('starred', $booleanNormalizer)
208213
;
214+
$resolver->setDefined('with_issues_enabled')
215+
->setAllowedTypes('with_issues_enabled', 'bool')
216+
->setNormalizer('with_issues_enabled', $booleanNormalizer)
217+
;
218+
$resolver->setDefined('with_merge_requests_enabled')
219+
->setAllowedTypes('with_merge_requests_enabled', 'bool')
220+
->setNormalizer('with_merge_requests_enabled', $booleanNormalizer)
221+
;
222+
$resolver->setDefined('with_shared')
223+
->setAllowedTypes('with_shared', 'bool')
224+
->setNormalizer('with_shared', $booleanNormalizer)
225+
;
226+
$resolver->setDefined('include_subgroups')
227+
->setAllowedTypes('include_subgroups', 'bool')
228+
->setNormalizer('include_subgroups', $booleanNormalizer)
229+
;
230+
$resolver->setDefined('with_custom_attributes')
231+
->setAllowedTypes('with_custom_attributes', 'bool')
232+
->setNormalizer('with_custom_attributes', $booleanNormalizer)
233+
;
209234

210235
return $this->get('groups/'.$this->encodePath($id).'/projects', $resolver->resolve($parameters));
211236
}

lib/Gitlab/Api/IssuesStatistics.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php namespace Gitlab\Api;
2+
3+
use Symfony\Component\OptionsResolver\Options;
4+
use Symfony\Component\OptionsResolver\OptionsResolver;
5+
6+
class IssuesStatistics extends AbstractApi
7+
{
8+
public function all($parameters)
9+
{
10+
return $this->get('issues_statistics', $this->createOptionsResolver()->resolve($parameters));
11+
}
12+
13+
public function project($project_id, $parameters)
14+
{
15+
return $this->get($this->getProjectPath($project_id, 'issues_statistics'), $this->createOptionsResolver()->resolve($parameters));
16+
}
17+
18+
public function group($group_id, $parameters)
19+
{
20+
return $this->get($this->getGroupPath($group_id, 'issues_statistics'), $this->createOptionsResolver()->resolve($parameters));
21+
}
22+
23+
protected function createOptionsResolver()
24+
{
25+
$resolver = new OptionsResolver();
26+
27+
$resolver->setDefined('milestone')
28+
->setAllowedTypes('milestone', 'string');
29+
30+
$resolver->setDefined('labels')
31+
->setAllowedTypes('labels', 'string');
32+
33+
$resolver->setDefined('scope')
34+
->setAllowedValues('scope', ['created-by-me', 'assigned-to-me', 'all']);
35+
36+
$resolver->setDefined('author_id')
37+
->setAllowedTypes('author_id', 'integer');
38+
39+
$resolver->setDefined('author_username')
40+
->setAllowedTypes('author_username', 'string');
41+
42+
$resolver->setDefined('assignee_id')
43+
->setAllowedTypes('assignee_id', 'integer');
44+
45+
$resolver->setDefined('assignee_username')
46+
->setAllowedTypes('assignee_username', 'string');
47+
48+
$resolver->setDefined('my_reaction_emoji')
49+
->setAllowedTypes('my_reaction_emoji', 'string');
50+
51+
$resolver->setDefined('search')
52+
->setAllowedTypes('search', 'string');
53+
54+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value) {
55+
return $value->format('c');
56+
};
57+
58+
$resolver->setDefined('created_after')
59+
->setAllowedTypes('created_after', \DateTimeInterface::class)
60+
->setNormalizer('created_after', $datetimeNormalizer);
61+
62+
$resolver->setDefined('created_before')
63+
->setAllowedTypes('created_before', \DateTimeInterface::class)
64+
->setNormalizer('created_before', $datetimeNormalizer);
65+
66+
$resolver->setDefined('updated_after')
67+
->setAllowedTypes('updated_after', \DateTimeInterface::class)
68+
->setNormalizer('updated_after', $datetimeNormalizer);
69+
70+
$resolver->setDefined('updated_before')
71+
->setAllowedTypes('updated_before', \DateTimeInterface::class)
72+
->setNormalizer('updated_before', $datetimeNormalizer);
73+
74+
$booleanNormalizer = function (Options $resolver, $value) {
75+
return $value ? 'true' : 'false';
76+
};
77+
78+
$resolver->setDefined('confidential')
79+
->setAllowedTypes('confidential', 'bool')
80+
->setNormalizer('confidential', $booleanNormalizer);
81+
82+
return $resolver;
83+
}
84+
}

lib/Gitlab/Api/Jobs.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ public function artifactsByRefName($project_id, $ref_name, $job_name)
8585
))->getBody();
8686
}
8787

88+
/**
89+
* @param int|string $project_id
90+
* @param string $ref_name
91+
* @param string $job_name
92+
* @param string $artifact_path
93+
* @return StreamInterface
94+
*/
95+
public function artifactByRefName($project_id, $ref_name, $job_name, $artifact_path)
96+
{
97+
return $this->getAsResponse("projects/".$this->encodePath($project_id)."/jobs/artifacts/".$this->encodePath($ref_name)."/raw/".$this->encodePath($artifact_path), array(
98+
'job' => $this->encodePath($job_name)
99+
))->getBody();
100+
}
101+
88102
/**
89103
* @param int|string $project_id
90104
* @param int $job_id

lib/Gitlab/Api/MergeRequests.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,27 @@ public function show($project_id, $mr_id)
109109
* @param string $source
110110
* @param string $target
111111
* @param string $title
112-
* @param int $assignee
113-
* @param int $target_project_id
114-
* @param string $description
112+
* @param int $assignee @deprecated will be moved into $optionalParams
113+
* @param int $target_project_id @deprecated will be moved into $optionalParams
114+
* @param string $description @deprecated will be moved into $optionalParams
115+
* @param array $optionalParams
115116
* @return mixed
116117
*/
117-
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null)
118+
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null, array $optionalParams = [])
118119
{
119-
return $this->post($this->getProjectPath($project_id, 'merge_requests'), array(
120+
$baseParams = [
120121
'source_branch' => $source,
121122
'target_branch' => $target,
122123
'title' => $title,
123124
'assignee_id' => $assignee,
125+
'description' => $description,
124126
'target_project_id' => $target_project_id,
125-
'description' => $description
126-
));
127+
];
128+
129+
return $this->post(
130+
$this->getProjectPath($project_id, 'merge_requests'),
131+
array_merge($baseParams, $optionalParams)
132+
);
127133
}
128134

129135
/**

lib/Gitlab/Api/Projects.php

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public function unarchive($project_id)
182182
* @var string $scope The scope of pipelines, one of: running, pending, finished, branches, tags.
183183
* @var string $status The status of pipelines, one of: running, pending, success, failed, canceled, skipped.
184184
* @var string $ref The ref of pipelines.
185+
* @var string $sha The sha of pipelines.
185186
* @var bool $yaml_errors Returns pipelines with invalid configurations.
186187
* @var string $name The name of the user who triggered pipelines.
187188
* @var string $username The username of the user who triggered pipelines.
@@ -204,6 +205,7 @@ public function pipelines($project_id, array $parameters = [])
204205
->setAllowedValues('status', ['running', 'pending', 'success', 'failed', 'canceled', 'skipped'])
205206
;
206207
$resolver->setDefined('ref');
208+
$resolver->setDefined('sha');
207209
$resolver->setDefined('yaml_errors')
208210
->setAllowedTypes('yaml_errors', 'bool')
209211
->setNormalizer('yaml_errors', $booleanNormalizer)
@@ -233,12 +235,26 @@ public function pipeline($project_id, $pipeline_id)
233235
/**
234236
* @param int $project_id
235237
* @param string $commit_ref
238+
* @param array $variables (
239+
* @var array (
240+
* @var string $key The name of the variable
241+
* @var mixed $value The value of the variable
242+
* @var string $variable_type env_var (default) or file
243+
* )
244+
* )
236245
* @return mixed
237246
*/
238-
public function createPipeline($project_id, $commit_ref)
247+
public function createPipeline($project_id, $commit_ref, $variables = null)
239248
{
240-
return $this->post($this->getProjectPath($project_id, 'pipeline'), array(
241-
'ref' => $commit_ref));
249+
$parameters = array(
250+
'ref' => $commit_ref,
251+
);
252+
253+
if ($variables !== null) {
254+
$parameters['variables'] = $variables;
255+
}
256+
257+
return $this->post($this->getProjectPath($project_id, 'pipeline'), $parameters);
242258
}
243259

244260
/**
@@ -260,7 +276,17 @@ public function cancelPipeline($project_id, $pipeline_id)
260276
{
261277
return $this->post($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id)).'/cancel');
262278
}
263-
279+
280+
/**
281+
* @param $project_id
282+
* @param $pipeline_id
283+
* @return mixed
284+
*/
285+
public function deletePipeline($project_id, $pipeline_id)
286+
{
287+
return $this->delete($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id)));
288+
}
289+
264290
/**
265291
* @param integer $project_id
266292
* @param array $parameters
@@ -374,6 +400,24 @@ public function hook($project_id, $hook_id)
374400
return $this->get($this->getProjectPath($project_id, 'hooks/'.$this->encodePath($hook_id)));
375401
}
376402

403+
/**
404+
* Get project users.
405+
*
406+
* See https://docs.gitlab.com/ee/api/projects.html#get-project-users for more info.
407+
*
408+
* @param int $project_id
409+
* Project id.
410+
* @param array $parameters
411+
* Url parameters.
412+
*
413+
* @return array
414+
* List of project users.
415+
*/
416+
public function users($project_id, array $parameters = [])
417+
{
418+
return $this->get($this->getProjectPath($project_id, 'users'), $parameters);
419+
}
420+
377421
/**
378422
* Get project issues.
379423
*
@@ -816,7 +860,7 @@ public function addShare($project_id, array $parameters = [])
816860
*/
817861
public function removeShare($project_id, $group_id)
818862
{
819-
return $this->delete($this->getProjectPath($project_id, 'services/'.$group_id));
863+
return $this->delete($this->getProjectPath($project_id, 'share/' . $group_id));
820864
}
821865

822866
/**
@@ -866,6 +910,17 @@ public function removeBadge($project_id, $badge_id)
866910
*/
867911
public function updateBadge($project_id, $badge_id, array $params = array())
868912
{
869-
return $this->put($this->getProjectPath($project_id, 'badges/' . $this->encodePath($badge_id)));
913+
return $this->put($this->getProjectPath($project_id, 'badges/' . $this->encodePath($badge_id)), $params);
914+
}
915+
916+
917+
/**
918+
* @param int $project_id
919+
* @param array $params
920+
* @return mixed
921+
*/
922+
public function addProtectedBranch($project_id, array $params = [])
923+
{
924+
return $this->post($this->getProjectPath($project_id, 'protected_branches'), $params);
870925
}
871926
}

lib/Gitlab/Api/Users.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function show($id)
6868
* @param int $id
6969
* @return mixed
7070
*/
71-
public function usersProjects($id)
71+
public function usersProjects($id, array $params = array())
7272
{
73-
return $this->get('users/'.$this->encodePath($id).'/projects');
73+
return $this->get('users/'.$this->encodePath($id).'/projects', $params);
7474
}
7575

7676
/**

0 commit comments

Comments
 (0)