1
0
Fork 0

Bitbucket: switch to v2 API

pull/7735/head
Stephan Vock 2018-10-19 11:55:45 +02:00
parent a1ead0e868
commit 819f487b38
2 changed files with 11 additions and 6 deletions

View File

@ -190,7 +190,7 @@ abstract class BitbucketDriver extends VcsDriver
} }
$resource = sprintf( $resource = sprintf(
'https://api.bitbucket.org/1.0/repositories/%s/%s/raw/%s/%s', 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
$this->owner, $this->owner,
$this->repository, $this->repository,
$identifier, $identifier,
@ -421,11 +421,16 @@ abstract class BitbucketDriver extends VcsDriver
protected function getMainBranchData() protected function getMainBranchData()
{ {
$resource = sprintf( $resource = sprintf(
'https://api.bitbucket.org/1.0/repositories/%s/%s/main-branch', 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
$this->owner, $this->owner,
$this->repository $this->repository
); );
return JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource); $data = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
if (isset($data['mainbranch'])) {
return $data['mainbranch'];
}
return null;
} }
} }

View File

@ -113,7 +113,7 @@ class GitBitbucketDriverTest extends TestCase
), ),
array( array(
$this->originUrl, $this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/main-branch', 'https://api.bitbucket.org/2.0/repositories/user/repo?fields=mainbranch',
false, false,
), ),
array( array(
@ -128,7 +128,7 @@ class GitBitbucketDriverTest extends TestCase
), ),
array( array(
$this->originUrl, $this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/raw/master/composer.json', 'https://api.bitbucket.org/2.0/repositories/user/repo/src/master/composer.json',
false, false,
), ),
array( array(
@ -139,7 +139,7 @@ class GitBitbucketDriverTest extends TestCase
) )
->willReturnOnConsecutiveCalls( ->willReturnOnConsecutiveCalls(
'{"scm":"git","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/tags"},"clone":[{"href":"https:\/\/user@bitbucket.org\/user\/repo.git","name":"https"},{"href":"ssh:\/\/git@bitbucket.org\/user\/repo.git","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/user\/repo"}},"language":"php","created_on":"2015-02-18T16:22:24.688+00:00","updated_on":"2016-05-17T13:20:21.993+00:00","is_private":true,"has_issues":false}', '{"scm":"git","website":"","has_wiki":false,"name":"repo","links":{"branches":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/branches"},"tags":{"href":"https:\/\/api.bitbucket.org\/2.0\/repositories\/user\/repo\/refs\/tags"},"clone":[{"href":"https:\/\/user@bitbucket.org\/user\/repo.git","name":"https"},{"href":"ssh:\/\/git@bitbucket.org\/user\/repo.git","name":"ssh"}],"html":{"href":"https:\/\/bitbucket.org\/user\/repo"}},"language":"php","created_on":"2015-02-18T16:22:24.688+00:00","updated_on":"2016-05-17T13:20:21.993+00:00","is_private":true,"has_issues":false}',
'{"name": "master"}', '{"mainbranch": {"name": "master"}}',
'{"values":[{"name":"1.0.1","target":{"hash":"9b78a3932143497c519e49b8241083838c8ff8a1"}},{"name":"1.0.0","target":{"hash":"d3393d514318a9267d2f8ebbf463a9aaa389f8eb"}}]}', '{"values":[{"name":"1.0.1","target":{"hash":"9b78a3932143497c519e49b8241083838c8ff8a1"}},{"name":"1.0.0","target":{"hash":"d3393d514318a9267d2f8ebbf463a9aaa389f8eb"}}]}',
'{"values":[{"name":"master","target":{"hash":"937992d19d72b5116c3e8c4a04f960e5fa270b22"}}]}', '{"values":[{"name":"master","target":{"hash":"937992d19d72b5116c3e8c4a04f960e5fa270b22"}}]}',
'{"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"}}', '{"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"}}',