Skip to content

Commit fe8df7d

Browse files
authored
Merge pull request #214 from fbourigault/v4-api-9637
update files repository endpoint for v4
2 parents a8f75fc + f10591d commit fe8df7d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/Gitlab/Api/Repositories.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ public function tree($project_id, array $params = array())
240240
*/
241241
public function blob($project_id, $sha, $filepath)
242242
{
243-
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/blob'), array(
244-
'filepath' => $filepath
243+
return $this->get($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($filepath).'/raw'), array(
244+
'ref' => $sha,
245245
));
246246
}
247247

@@ -253,8 +253,7 @@ public function blob($project_id, $sha, $filepath)
253253
*/
254254
public function getFile($project_id, $file_path, $ref)
255255
{
256-
return $this->get($this->getProjectPath($project_id, 'repository/files'), array(
257-
'file_path' => $file_path,
256+
return $this->get($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($file_path)), array(
258257
'ref' => $ref
259258
));
260259
}

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public function shouldGetBlob()
461461
$api = $this->getApiMock();
462462
$api->expects($this->once())
463463
->method('get')
464-
->with('projects/1/repository/commits/abcd1234/blob', array('filepath' => 'dir/file1.txt'))
464+
->with('projects/1/repository/files/dir%2Ffile1%2Etxt/raw', array('ref' => 'abcd1234'))
465465
->will($this->returnValue($expectedString))
466466
;
467467

@@ -478,7 +478,7 @@ public function shouldGetFile()
478478
$api = $this->getApiMock();
479479
$api->expects($this->once())
480480
->method('get')
481-
->with('projects/1/repository/files', array('file_path' => 'dir/file1.txt', 'ref' => 'abcd1234'))
481+
->with('projects/1/repository/files/dir%2Ffile1%2Etxt', array('ref' => 'abcd1234'))
482482
->will($this->returnValue($expectedArray))
483483
;
484484

0 commit comments

Comments
 (0)