Skip to content

Commit 72bf48c

Browse files
owencontim1guelpf
authored andcommitted
Add ability to list releases.
1 parent b857296 commit 72bf48c

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/Gitlab/Api/Repositories.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ public function updateRelease($project_id, $tag_name, $description)
136136
));
137137
}
138138

139+
/**
140+
* @param int $project_id
141+
* @return mixed
142+
*/
143+
public function releases($project_id)
144+
{
145+
$resolver = $this->createOptionsResolver();
146+
return $this->get($this->getProjectPath($project_id, 'releases'));
147+
}
148+
139149
/**
140150
* @param int $project_id
141151
* @param array $parameters (
@@ -190,8 +200,10 @@ public function commitRefs($project_id, $sha, array $parameters = [])
190200
{
191201
$resolver = $this->createOptionsResolver();
192202

193-
return $this->get($this->getProjectPath($project_id, 'repository/commits/' . $this->encodePath($sha) . '/refs'),
194-
$resolver->resolve($parameters));
203+
return $this->get(
204+
$this->getProjectPath($project_id, 'repository/commits/' . $this->encodePath($sha) . '/refs'),
205+
$resolver->resolve($parameters)
206+
);
195207
}
196208

197209
/**

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,29 @@ public function shouldUpdateRelease()
217217

218218
$this->assertEquals($expectedArray, $api->updateRelease($project_id, $tagName, $description));
219219
}
220+
221+
/**
222+
* @test
223+
*/
224+
public function shouldGetReleases()
225+
{
226+
$expectedArray = array(
227+
array(
228+
'tag_name' => 'v0.2',
229+
'description' => '## CHANGELOG\r\n\r\n- Escape label and milestone titles to prevent XSS in GFM autocomplete. !2740\r\n- Prevent private snippets from being embeddable.\r\n- Add subresources removal to member destroy service.',
230+
'name' => 'Awesome app v0.2 beta'
231+
)
232+
);
233+
234+
$api = $this->getApiMock();
235+
$api->expects($this->once())
236+
->method('get')
237+
->with('projects/1/releases')
238+
->will($this->returnValue($expectedArray))
239+
;
240+
241+
$this->assertEquals($expectedArray, $api->releases());
242+
}
220243

221244
/**
222245
* @test

0 commit comments

Comments
 (0)