Skip to content

Commit cabc645

Browse files
Matth--m1guelpf
authored andcommitted
Branches API: add search attribute
The branches api can have an optional "search" parameter to filter for branch names
1 parent c07fa69 commit cabc645

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Gitlab/Api/Repositories.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ class Repositories extends AbstractApi
1010

1111
/**
1212
* @param int $project_id
13-
* @param array $parameters
13+
* @param array $parameters (
14+
*
15+
* @var string $search
16+
* )
1417
* @return mixed
1518
*/
1619
public function branches($project_id, array $parameters = [])
1720
{
1821
$resolver = $this->createOptionsResolver();
22+
$resolver->setDefined('search')
23+
->setAllowedTypes('search', 'string');
24+
1925
return $this->get($this->getProjectPath($project_id, 'repository/branches'), $resolver->resolve($parameters));
2026
}
2127

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public function shouldGetBranches()
1818
$api = $this->getApiMock();
1919
$api->expects($this->once())
2020
->method('get')
21-
->with('projects/1/repository/branches')
21+
->with('projects/1/repository/branches', ['search' => '^term'])
2222
->will($this->returnValue($expectedArray))
2323
;
2424

25-
$this->assertEquals($expectedArray, $api->branches(1));
25+
$this->assertEquals($expectedArray, $api->branches(1, ['search' => '^term']));
2626
}
2727

2828
/**
@@ -217,7 +217,7 @@ public function shouldUpdateRelease()
217217

218218
$this->assertEquals($expectedArray, $api->updateRelease($project_id, $tagName, $description));
219219
}
220-
220+
221221
/**
222222
* @test
223223
*/

0 commit comments

Comments
 (0)