Use the api to get file contents instead of raw.github.com
raw.github does not like the access_token query parampull/1629/head
parent
5454645cf3
commit
259a25344d
|
@ -128,8 +128,11 @@ class GitHubDriver extends VcsDriver
|
||||||
|
|
||||||
if (!isset($this->infoCache[$identifier])) {
|
if (!isset($this->infoCache[$identifier])) {
|
||||||
try {
|
try {
|
||||||
$resource = 'https://raw.github.com/'.$this->owner.'/'.$this->repository.'/'.$identifier.'/composer.json';
|
$resource = 'https://api.github.com/repos/'.$this->owner.'/'.$this->repository.'/contents/composer.json?ref='.urlencode($identifier);
|
||||||
$composer = $this->getContents($resource);
|
$composer = JsonFile::parseJson($this->getContents($resource));
|
||||||
|
if (empty($composer['content']) || $composer['encoding'] !== 'base64' || !($composer = base64_decode($composer['content']))) {
|
||||||
|
throw new \RuntimeException('Could not retrieve composer.json from '.$resource);
|
||||||
|
}
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
if (404 !== $e->getCode()) {
|
if (404 !== $e->getCode()) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|
|
@ -198,8 +198,8 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$remoteFilesystem->expects($this->at(1))
|
$remoteFilesystem->expects($this->at(1))
|
||||||
->method('getContents')
|
->method('getContents')
|
||||||
->with($this->equalTo('github.com'), $this->equalTo('https://raw.github.com/composer/packagist/feature/3.2-foo/composer.json'), $this->equalTo(false))
|
->with($this->equalTo('github.com'), $this->equalTo('https://api.github.com/repos/composer/packagist/contents/composer.json?ref=feature%2F3.2-foo'), $this->equalTo(false))
|
||||||
->will($this->returnValue('{"support": {"source": "'.$repoUrl.'" }}'));
|
->will($this->returnValue('{"encoding":"base64","content":"'.base64_encode('{"support": {"source": "'.$repoUrl.'" }}').'"}'));
|
||||||
|
|
||||||
$remoteFilesystem->expects($this->at(2))
|
$remoteFilesystem->expects($this->at(2))
|
||||||
->method('getContents')
|
->method('getContents')
|
||||||
|
|
Loading…
Reference in New Issue