Skip to content

Commit 57e8095

Browse files
Merge branch '10.2' into 11.0
2 parents a39780d + 30a5501 commit 57e8095

File tree

5 files changed

+165
-32
lines changed

5 files changed

+165
-32
lines changed

CHANGELOG.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,62 @@
1-
CHANGE LOG
2-
==========
1+
# Changelog
32

3+
All notable changes to this project will be documented in this file.
44

5-
## 11.0.0-RC1 (UPCOMING)
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [11.0.0-RC1] - UPCOMING
69

710
* Removed models API
811
* Bumped min PHP to 7.2.5
912

13+
[11.0.0-RC1]: https://github.com/GitLabPHP/Client/compare/10.2.0...11.0.0-RC1
14+
15+
## [10.2.0] - UPCOMING
1016

11-
## 10.2.0 (UPCOMING)
17+
* Added variable_type to addVariable and updateVariable
1218

19+
[10.2.0]: https://github.com/GitLabPHP/Client/compare/10.1.1...10.2.0
1320

14-
## 10.1.1 (26/10/2020)
21+
## [10.1.1] - 2020-10-26
1522

1623
* Fixed phpdoc typo
1724
* Fixed broken query builder
1825

26+
[10.1.1]: https://github.com/GitLabPHP/Client/compare/10.1.0...10.1.1
1927

20-
## 10.1.0 (24/10/2020)
28+
## [10.1.0] - 2020-10-24
2129

2230
* Added method to get protected branches for a project
2331
* Added with_merge_status_recheck option for fetching MRs
2432
* Added commit cherry-pick API
2533
* Added support for optional Note parameters
2634
* Deprecated models API
2735

36+
[10.1.0]: https://github.com/GitLabPHP/Client/compare/10.0.1...10.1.0
2837

29-
## 10.0.1 (24/10/2020)
38+
## [10.0.1] - 2020-10-24
3039

3140
* Fixed using the name of a group as an ID
3241
* Fixed various phpdoc issues
3342
* Reverted query builder changes
3443

44+
[10.0.1]: https://github.com/GitLabPHP/Client/compare/10.0.0...10.0.1
3545

36-
## 10.0.0 (15/08/2020)
46+
## [10.0.0] - 2020-08-15
3747

3848
* Added void return types to void methods
3949

50+
[10.0.0]: https://github.com/GitLabPHP/Client/compare/10.0.0-RC2...10.0.0
4051

41-
## 10.0.0-RC2 (23/07/2020)
52+
## [10.0.0-RC2] - 2020-07-23
4253

4354
* Restored 9.x behaviour for empty JSON responses
4455
* Support the issue link link_type parameter
4556

57+
[10.0.0-RC2]: https://github.com/GitLabPHP/Client/compare/10.0.0-RC1...10.0.0-RC2
4658

47-
## 10.0.0-RC1 (22/07/2020)
59+
## [10.0.0-RC1] - 2020-07-22
4860

4961
* Removed all deprecated functionality
5062
* Switched to PSR-17 and PSR-18
@@ -55,14 +67,16 @@ CHANGE LOG
5567
* Added scalar param types
5668
* Added user events API
5769

70+
[10.0.0-RC1]: https://github.com/GitLabPHP/Client/compare/9.18.1...10.0.0-RC1
5871

59-
## 9.18.1 (22/07/2020)
72+
## [9.18.1] - 2020-07-22
6073

6174
* Fixed error in getHeader function
6275
* Fixed incorrect param type doc
6376

77+
[9.18.1]: https://github.com/GitLabPHP/Client/compare/9.18.0...9.18.1
6478

65-
## 9.18.0 (11/07/2020)
79+
## [9.18.0] - 2020-07-11
6680

6781
* Deprecated all APIs that are deprecated or removed as of GitLab 13.1
6882
* Deprecated old authentication methods and deprecated not specifying an authentication mode
@@ -82,18 +96,22 @@ CHANGE LOG
8296
* Allow to search and find issues by "assignee_id"
8397
* Updated Issues to support updated_after
8498

99+
[9.18.0]: https://github.com/GitLabPHP/Client/compare/9.17.1...9.18.0
85100

86-
## 9.17.1 (17/02/2020)
101+
## [9.17.1] - 2020-02-17
87102

88103
* Fixed text encoding for `Repositories::createCommit()`
89104
* Corrected lots of phpdoc errors and edges cases
90105

106+
[9.17.1]: https://github.com/GitLabPHP/Client/compare/9.17.0...9.17.1
91107

92-
## 9.17.0 (17/02/2020)
108+
## [9.17.0] - 2020-02-17
93109

94110
* Added support for the wiki APIs
95111
* Implemented `Environments::show()`
96112
* Implemented `Issues::showParticipants()`
97113
* Add method to get issues for a group
98114
* Add forks API call to return all forked projects
99115
* Added users projects request parameters normalization
116+
117+
[9.17.0]: https://github.com/GitLabPHP/Client/compare/9.16.0...9.17.0

src/Api/Projects.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -848,15 +848,19 @@ public function variable($project_id, string $key)
848848
}
849849

850850
/**
851-
* @param int|string $project_id
852-
* @param string $key
853-
* @param string $value
854-
* @param bool|null $protected
855-
* @param string|null $environment_scope
851+
* @param int|string $project_id
852+
* @param string $key
853+
* @param string $value
854+
* @param bool|null $protected
855+
* @param string|null $environment_scope
856+
* @param array<string,mixed> $parameters {
857+
*
858+
* @var string $variable_type env_var (default) or file
859+
* }
856860
*
857861
* @return mixed
858862
*/
859-
public function addVariable($project_id, string $key, string $value, ?bool $protected = null, ?string $environment_scope = null)
863+
public function addVariable($project_id, string $key, string $value, ?bool $protected = null, ?string $environment_scope = null, array $parameters = [])
860864
{
861865
$payload = [
862866
'key' => $key,
@@ -871,19 +875,25 @@ public function addVariable($project_id, string $key, string $value, ?bool $prot
871875
$payload['environment_scope'] = $environment_scope;
872876
}
873877

878+
$payload = \array_merge($parameters, $payload);
879+
874880
return $this->post($this->getProjectPath($project_id, 'variables'), $payload);
875881
}
876882

877883
/**
878-
* @param int|string $project_id
879-
* @param string $key
880-
* @param string $value
881-
* @param bool|null $protected
882-
* @param string|null $environment_scope
884+
* @param int|string $project_id
885+
* @param string $key
886+
* @param string $value
887+
* @param bool|null $protected
888+
* @param string|null $environment_scope
889+
* @param array<string,mixed> $parameters {
890+
*
891+
* @var string $variable_type env_var (default) or file
892+
*}
883893
*
884894
* @return mixed
885895
*/
886-
public function updateVariable($project_id, string $key, string $value, ?bool $protected = null, ?string $environment_scope = null)
896+
public function updateVariable($project_id, string $key, string $value, ?bool $protected = null, ?string $environment_scope = null, array $parameters = [])
887897
{
888898
$payload = [
889899
'value' => $value,
@@ -897,6 +907,8 @@ public function updateVariable($project_id, string $key, string $value, ?bool $p
897907
$payload['environment_scope'] = $environment_scope;
898908
}
899909

910+
$payload = \array_merge($parameters, $payload);
911+
900912
return $this->put($this->getProjectPath($project_id, 'variables/'.self::encodePath($key)), $payload);
901913
}
902914

src/Api/Repositories.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,13 @@ public function postCommitBuildStatus($project_id, string $sha, string $state, a
386386
*/
387387
public function compare($project_id, string $fromShaOrMaster, string $toShaOrMaster, bool $straight = false)
388388
{
389-
return $this->get($this->getProjectPath(
390-
$project_id,
391-
'repository/compare?from='.self::encodePath($fromShaOrMaster).'&to='.self::encodePath($toShaOrMaster).'&straight='.self::encodePath($straight ? 'true' : 'false')
392-
));
389+
$params = [
390+
'from' => self::encodePath($fromShaOrMaster),
391+
'to' => self::encodePath($toShaOrMaster),
392+
'straight' => self::encodePath($straight ? 'true' : 'false'),
393+
];
394+
395+
return $this->get($this->getProjectPath($project_id, 'repository/compare'), $params);
393396
}
394397

395398
/**

tests/Api/ProjectsTest.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,53 @@ public function shouldAddVariableWithProtectionAndEnvironment(): void
16091609
);
16101610
}
16111611

1612+
/**
1613+
* @test
1614+
*/
1615+
public function shouldAddVariableWithEnvironmentAndVariableType(): void
1616+
{
1617+
$expectedArray = [
1618+
'key' => 'DEPLOY_SERVER',
1619+
'value' => 'stage.example.com',
1620+
'environment_scope' => 'staging',
1621+
'variable_type' => 'file',
1622+
];
1623+
1624+
$api = $this->getApiMock();
1625+
$api->expects($this->once())
1626+
->method('post')
1627+
->with('projects/1/variables', $expectedArray)
1628+
->will($this->returnValue($expectedArray));
1629+
1630+
$this->assertEquals(
1631+
$expectedArray,
1632+
$api->addVariable(1, 'DEPLOY_SERVER', 'stage.example.com', null, 'staging', ['variable_type' => 'file'])
1633+
);
1634+
}
1635+
1636+
/**
1637+
* @test
1638+
*/
1639+
public function shouldAddVariableWithEnvironmentFromParameterList(): void
1640+
{
1641+
$expectedArray = [
1642+
'key' => 'DEPLOY_SERVER',
1643+
'value' => 'stage.example.com',
1644+
'environment_scope' => 'staging',
1645+
];
1646+
1647+
$api = $this->getApiMock();
1648+
$api->expects($this->once())
1649+
->method('post')
1650+
->with('projects/1/variables', $expectedArray)
1651+
->will($this->returnValue($expectedArray));
1652+
1653+
$this->assertEquals(
1654+
$expectedArray,
1655+
$api->addVariable(1, 'DEPLOY_SERVER', 'stage.example.com', null, 'staging', ['environment_scope' => 'production'])
1656+
);
1657+
}
1658+
16121659
/**
16131660
* @test
16141661
*/
@@ -1704,6 +1751,59 @@ public function shouldUpdateVariableWithProtectedAndEnvironment(): void
17041751
);
17051752
}
17061753

1754+
/**
1755+
* @test
1756+
*/
1757+
public function shouldUpdateVariableWithEnvironmentAndVariableType(): void
1758+
{
1759+
$expectedArray = [
1760+
'key' => 'DEPLOY_SERVER',
1761+
'value' => 'stage.example.com',
1762+
'environment_scope' => 'staging',
1763+
'variable_type' => 'file',
1764+
];
1765+
1766+
$api = $this->getApiMock();
1767+
$api->expects($this->once())
1768+
->method('put')
1769+
->with(
1770+
'projects/1/variables/DEPLOY_SERVER',
1771+
['value' => 'stage.example.com', 'environment_scope' => 'staging', 'variable_type' => 'file']
1772+
)
1773+
->will($this->returnValue($expectedArray));
1774+
1775+
$this->assertEquals(
1776+
$expectedArray,
1777+
$api->updateVariable(1, 'DEPLOY_SERVER', 'stage.example.com', null, 'staging', ['variable_type' => 'file'])
1778+
);
1779+
}
1780+
1781+
/**
1782+
* @test
1783+
*/
1784+
public function shouldUpdateVariableWithEnvironmentFromParameterList(): void
1785+
{
1786+
$expectedArray = [
1787+
'key' => 'DEPLOY_SERVER',
1788+
'value' => 'stage.example.com',
1789+
'environment_scope' => 'staging',
1790+
];
1791+
1792+
$api = $this->getApiMock();
1793+
$api->expects($this->once())
1794+
->method('put')
1795+
->with(
1796+
'projects/1/variables/DEPLOY_SERVER',
1797+
['value' => 'stage.example.com', 'environment_scope' => 'staging']
1798+
)
1799+
->will($this->returnValue($expectedArray));
1800+
1801+
$this->assertEquals(
1802+
$expectedArray,
1803+
$api->updateVariable(1, 'DEPLOY_SERVER', 'stage.example.com', null, 'staging', ['environment_scope' => 'production'])
1804+
);
1805+
}
1806+
17071807
/**
17081808
* @test
17091809
*/

tests/Api/RepositoriesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public function shouldCompareStraight(): void
490490
$api = $this->getApiMock();
491491
$api->expects($this->once())
492492
->method('get')
493-
->with('projects/1/repository/compare?from=master&to=feature&straight=true')
493+
->with('projects/1/repository/compare', ['from' => 'master', 'to' => 'feature', 'straight' => 'true'])
494494
->will($this->returnValue($expectedArray))
495495
;
496496

@@ -507,7 +507,7 @@ public function shouldNotCompareStraight(): void
507507
$api = $this->getApiMock();
508508
$api->expects($this->once())
509509
->method('get')
510-
->with('projects/1/repository/compare?from=master&to=feature&straight=false')
510+
->with('projects/1/repository/compare', ['from' => 'master', 'to' => 'feature', 'straight' => 'false'])
511511
->will($this->returnValue($expectedArray))
512512
;
513513

0 commit comments

Comments
 (0)