1
0
Fork 0

Refactor the getRepoData method to not throw an Exception

pull/6094/head
Stefan Grootscholten 2017-01-29 15:35:50 +01:00
parent 4377ba2bcb
commit 3ccaac619b
4 changed files with 5 additions and 25 deletions

View File

@ -77,7 +77,7 @@ abstract class BitbucketDriver extends VcsDriver
* Attempts to fetch the repository data via the BitBucket API and * Attempts to fetch the repository data via the BitBucket API and
* sets some parameters which are used in other methods * sets some parameters which are used in other methods
* *
* @return void * @return bool
*/ */
protected function getRepoData() protected function getRepoData()
{ {
@ -94,7 +94,7 @@ abstract class BitbucketDriver extends VcsDriver
$repoData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource, true), $resource); $repoData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource, true), $resource);
if ($this->fallbackDriver) { if ($this->fallbackDriver) {
throw new BitbucketFallbackException(); return false;
} }
$this->parseCloneUrls($repoData['links']['clone']); $this->parseCloneUrls($repoData['links']['clone']);
@ -104,6 +104,7 @@ abstract class BitbucketDriver extends VcsDriver
$this->homeUrl = $repoData['links']['html']['href']; $this->homeUrl = $repoData['links']['html']['href'];
$this->website = $repoData['website']; $this->website = $repoData['website'];
$this->vcsType = $repoData['scm']; $this->vcsType = $repoData['scm'];
return true;
} }
/** /**

View File

@ -1,17 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Repository\Vcs;
class BitbucketFallbackException extends \RuntimeException
{
}

View File

@ -30,9 +30,7 @@ class GitBitbucketDriver extends BitbucketDriver
} }
if (null === $this->rootIdentifier) { if (null === $this->rootIdentifier) {
try { if (! $this->getRepoData()) {
$this->getRepoData();
} catch (BitbucketFallbackException $e) {
return $this->fallbackDriver->getRootIdentifier(); return $this->fallbackDriver->getRootIdentifier();
} }

View File

@ -30,9 +30,7 @@ class HgBitbucketDriver extends BitbucketDriver
} }
if (null === $this->rootIdentifier) { if (null === $this->rootIdentifier) {
try { if (! $this->getRepoData()) {
$this->getRepoData();
} catch (BitbucketFallbackException $e) {
return $this->fallbackDriver->getRootIdentifier(); return $this->fallbackDriver->getRootIdentifier();
} }