1
0
Fork 0

Improve fetching single files via bitbucket API.

The former implementation used the 'src' endpoint which returned some meta data as well.
This has been replaced with the 'raw' endpoint which does not return the meta data and does not need an extra JSON decode step.
pull/6094/head
Stefan Grootscholten 2016-12-28 22:43:24 +01:00
parent 3eeb6214eb
commit 7ae4ed1ec8
2 changed files with 4 additions and 8 deletions

View File

@ -166,18 +166,14 @@ abstract class BitbucketDriver extends VcsDriver
}
$resource = sprintf(
'https://api.bitbucket.org/1.0/repositories/%s/%s/src/%s/%s',
'https://api.bitbucket.org/1.0/repositories/%s/%s/raw/%s/%s',
$this->owner,
$this->repository,
$identifier,
$file
);
$fileData = JsonFile::parseJson($this->getContents($resource), $resource);
if (!is_array($fileData) || ! array_key_exists('data', $fileData)) {
return null;
}
return $fileData['data'];
return $this->getContents($resource);
}
/**

View File

@ -128,7 +128,7 @@ class GitBitbucketDriverTest extends TestCase
),
array(
$this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/src/master/composer.json',
'https://api.bitbucket.org/1.0/repositories/user/repo/raw/master/composer.json',
false
),
array(
@ -142,7 +142,7 @@ class GitBitbucketDriverTest extends TestCase
'{"name": "master"}',
'{"values":[{"name":"1.0.1","target":{"hash":"9b78a3932143497c519e49b8241083838c8ff8a1"}},{"name":"1.0.0","target":{"hash":"d3393d514318a9267d2f8ebbf463a9aaa389f8eb"}}]}',
'{"values":[{"name":"master","target":{"hash":"937992d19d72b5116c3e8c4a04f960e5fa270b22"}}]}',
'{"node": "937992d19d72", "path": "composer.json", "data": "{\n \"name\": \"user/repo\",\n \"description\": \"test repo\",\n \"license\": \"GPL\",\n \"authors\": [\n {\n \"name\": \"Name\",\n \"email\": \"local@domain.tld\"\n }\n ],\n \"require\": {\n \"creator/package\": \"^1.0\"\n },\n \"require-dev\": {\n \"phpunit/phpunit\": \"~4.8\"\n }\n}\n", "size": 269}',
'{"name": "user/repo","description": "test repo","license": "GPL","authors": [{"name": "Name","email": "local@domain.tld"}],"require": {"creator/package": "^1.0"},"require-dev": {"phpunit/phpunit": "~4.8"}}',
'{"node": "937992d19d72", "files": [{"type": "modified", "file": "path/to/file"}], "raw_author": "User <local@domain.tld>", "utctimestamp": "2016-05-17 11:19:52+00:00", "author": "user", "timestamp": "2016-05-17 13:19:52", "raw_node": "937992d19d72b5116c3e8c4a04f960e5fa270b22", "parents": ["71e195a33361"], "branch": "master", "message": "Commit message\n", "revision": null, "size": -1}'
);