Implement changes after review of stof.
Rename getContents to getContentsWithOAuthCredentials. Make gitDriver a private property.pull/5363/head
parent
1084a3927e
commit
d9fd9fca6b
|
@ -24,6 +24,9 @@ use Composer\Util\Bitbucket;
|
||||||
*/
|
*/
|
||||||
class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
protected $cache;
|
protected $cache;
|
||||||
protected $owner;
|
protected $owner;
|
||||||
protected $repository;
|
protected $repository;
|
||||||
|
@ -34,7 +37,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
/**
|
/**
|
||||||
* @var GitDriver
|
* @var GitDriver
|
||||||
*/
|
*/
|
||||||
protected $gitDriver;
|
private $gitDriver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -59,7 +62,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
|
|
||||||
if (null === $this->rootIdentifier) {
|
if (null === $this->rootIdentifier) {
|
||||||
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository;
|
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository;
|
||||||
$repoData = JsonFile::parseJson($this->getContents($resource, true), $resource);
|
$repoData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource, true), $resource);
|
||||||
$this->rootIdentifier = !empty($repoData['main_branch']) ? $repoData['main_branch'] : 'master';
|
$this->rootIdentifier = !empty($repoData['main_branch']) ? $repoData['main_branch'] : 'master';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,16 +118,16 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
|
|
||||||
if (!isset($this->infoCache[$identifier])) {
|
if (!isset($this->infoCache[$identifier])) {
|
||||||
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/src/'.$identifier.'/composer.json';
|
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/src/'.$identifier.'/composer.json';
|
||||||
$file = JsonFile::parseJson($this->getContents($resource), $resource);
|
$file = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
|
||||||
if (!is_array($file) || ! array_key_exists('data', $file)) {
|
if (!is_array($file) || ! array_key_exists('data', $file)) {
|
||||||
return;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$composer = JsonFile::parseJson($file['data'], $resource);
|
$composer = JsonFile::parseJson($file['data'], $resource);
|
||||||
|
|
||||||
if (empty($composer['time'])) {
|
if (empty($composer['time'])) {
|
||||||
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier;
|
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier;
|
||||||
$changeset = JsonFile::parseJson($this->getContents($resource), $resource);
|
$changeset = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
|
||||||
$composer['time'] = $changeset['timestamp'];
|
$composer['time'] = $changeset['timestamp'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +152,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
|
|
||||||
if (null === $this->tags) {
|
if (null === $this->tags) {
|
||||||
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
|
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
|
||||||
$tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
|
$tagsData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
|
||||||
$this->tags = array();
|
$this->tags = array();
|
||||||
foreach ($tagsData as $tag => $data) {
|
foreach ($tagsData as $tag => $data) {
|
||||||
$this->tags[$tag] = $data['raw_node'];
|
$this->tags[$tag] = $data['raw_node'];
|
||||||
|
@ -170,7 +173,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
|
|
||||||
if (null === $this->branches) {
|
if (null === $this->branches) {
|
||||||
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/branches';
|
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/branches';
|
||||||
$branchData = JsonFile::parseJson($this->getContents($resource), $resource);
|
$branchData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
|
||||||
$this->branches = array();
|
$this->branches = array();
|
||||||
foreach ($branchData as $branch => $data) {
|
foreach ($branchData as $branch => $data) {
|
||||||
$this->branches[$branch] = $data['raw_node'];
|
$this->branches[$branch] = $data['raw_node'];
|
||||||
|
@ -217,7 +220,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function generateSshUrl()
|
private function generateSshUrl()
|
||||||
{
|
{
|
||||||
return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
|
return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
|
||||||
}
|
}
|
||||||
|
@ -230,7 +233,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
*
|
*
|
||||||
* @return mixed The result
|
* @return mixed The result
|
||||||
*/
|
*/
|
||||||
protected function getContents($url, $fetchingRepoData = false)
|
protected function getContentsWithOAuthCredentials($url, $fetchingRepoData = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return parent::getContents($url);
|
return parent::getContents($url);
|
||||||
|
@ -258,7 +261,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
/**
|
/**
|
||||||
* @param string $url
|
* @param string $url
|
||||||
*/
|
*/
|
||||||
protected function setupGitDriver($url)
|
private function setupGitDriver($url)
|
||||||
{
|
{
|
||||||
$this->gitDriver = new GitDriver(
|
$this->gitDriver = new GitDriver(
|
||||||
array('url' => $url),
|
array('url' => $url),
|
||||||
|
|
Loading…
Reference in New Issue