1
0
Fork 0

CS tweaks, refs #6592

pull/6595/head
Jordi Boggiano 2017-08-08 10:11:35 +02:00
parent 6fd504ef41
commit c89f6338c2
2 changed files with 11 additions and 8 deletions

View File

@ -447,12 +447,12 @@ class GitLabDriver extends VcsDriver
return true; return true;
} }
protected function getNextPage() private function getNextPage()
{ {
$headers = $this->remoteFilesystem->getLastHeaders(); $headers = $this->remoteFilesystem->getLastHeaders();
foreach ($headers as $header) { foreach ($headers as $header) {
if (substr($header, 0, 5) === 'Link:') { if (preg_match('{^link:\s*(.+?)\s*$}i', $header, $match)) {
$links = explode(',', substr($header, 5)); $links = explode(',', $match[1]);
foreach ($links as $link) { foreach ($links as $link) {
if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) { if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
return $match[1]; return $match[1];

View File

@ -268,7 +268,10 @@ JSON;
; ;
$this->remoteFilesystem->getLastHeaders() $this->remoteFilesystem->getLastHeaders()
->willReturn(array('Link: <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=2&per_page=20>; rel="next", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=1&per_page=20>; rel="first", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=3&per_page=20>; rel="last"'), array('Link: <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=2&per_page=20>; rel="prev", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=1&per_page=20>; rel="first", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=3&per_page=20>; rel="last"')) ->willReturn(
array('Link: <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=2&per_page=20>; rel="next", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=1&per_page=20>; rel="first", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=3&per_page=20>; rel="last"'),
array('Link: <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=2&per_page=20>; rel="prev", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=1&per_page=20>; rel="first", <http://gitlab.com/api/v4/projects/mygroup%2Fmyproject/repository/tags?id=mygroup%2Fmyproject&page=3&per_page=20>; rel="last"')
)
->shouldBeCalledTimes(2); ->shouldBeCalledTimes(2);
$driver->setRemoteFilesystem($this->remoteFilesystem->reveal()); $driver->setRemoteFilesystem($this->remoteFilesystem->reveal());