Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialDiff.php
<?php | <?php | ||||
final class DifferentialDiff | final class DifferentialDiff | ||||
extends DifferentialDAO | extends DifferentialDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
HarbormasterBuildableInterface, | HarbormasterBuildableInterface, | ||||
HarbormasterCircleCIBuildableInterface, | |||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface { | ||||
protected $revisionID; | protected $revisionID; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $repositoryPHID; | protected $repositoryPHID; | ||||
protected $sourceMachine; | protected $sourceMachine; | ||||
▲ Show 20 Lines • Show All 503 Lines • ▼ Show 20 Lines | return array( | ||||
pht('The URI to clone or checkout the repository from.'), | pht('The URI to clone or checkout the repository from.'), | ||||
'repository.staging.uri' => | 'repository.staging.uri' => | ||||
pht('The URI of the staging repository.'), | pht('The URI of the staging repository.'), | ||||
'repository.staging.ref' => | 'repository.staging.ref' => | ||||
pht('The ref name for this change in the staging repository.'), | pht('The ref name for this change in the staging repository.'), | ||||
); | ); | ||||
} | } | ||||
/* -( HarbormasterCircleCIBuildableInterface )----------------------------- */ | |||||
public function getCircleCIGitHubRepositoryURI() { | |||||
$diff_phid = $this->getPHID(); | |||||
$repository_phid = $this->getRepositoryPHID(); | |||||
if (!$repository_phid) { | |||||
throw new Exception( | |||||
pht( | |||||
'This diff ("%s") is not associated with a repository. A diff '. | |||||
'must belong to a tracked repository to be built by CircleCI.', | |||||
$diff_phid)); | |||||
} | |||||
$repository = id(new PhabricatorRepositoryQuery()) | |||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | |||||
->withPHIDs(array($repository_phid)) | |||||
->executeOne(); | |||||
if (!$repository) { | |||||
throw new Exception( | |||||
pht( | |||||
'This diff ("%s") is associated with a repository ("%s") which '. | |||||
'could not be loaded.', | |||||
$diff_phid, | |||||
$repository_phid)); | |||||
} | |||||
$staging_uri = $repository->getStagingURI(); | |||||
if (!$staging_uri) { | |||||
throw new Exception( | |||||
pht( | |||||
'This diff ("%s") is associated with a repository ("%s") that '. | |||||
'does not have a Staging Area configured. You must configure a '. | |||||
'Staging Area to use CircleCI integration.', | |||||
$diff_phid, | |||||
$repository_phid)); | |||||
} | |||||
$path = HarbormasterCircleCIBuildStepImplementation::getGitHubPath( | |||||
$staging_uri); | |||||
if (!$path) { | |||||
throw new Exception( | |||||
pht( | |||||
'This diff ("%s") is associated with a repository ("%s") that '. | |||||
'does not have a Staging Area ("%s") that is hosted on GitHub. '. | |||||
'CircleCI can only build from GitHub, so the Staging Area for '. | |||||
'the repository must be hosted there.', | |||||
$diff_phid, | |||||
$repository_phid, | |||||
$staging_uri)); | |||||
} | |||||
return $staging_uri; | |||||
} | |||||
public function getCircleCIBuildIdentifierType() { | |||||
return 'tag'; | |||||
} | |||||
public function getCircleCIBuildIdentifier() { | |||||
$ref = $this->getStagingRef(); | |||||
$ref = preg_replace('(^refs/tags/)', '', $ref); | |||||
return $ref; | |||||
} | |||||
public function getStagingRef() { | public function getStagingRef() { | ||||
// TODO: We're just hoping to get lucky. Instead, `arc` should store | // TODO: We're just hoping to get lucky. Instead, `arc` should store | ||||
// where it sent changes and we should only provide staging details | // where it sent changes and we should only provide staging details | ||||
// if we reasonably believe they are accurate. | // if we reasonably believe they are accurate. | ||||
return 'refs/tags/phabricator/diff/'.$this->getID(); | return 'refs/tags/phabricator/diff/'.$this->getID(); | ||||
} | } | ||||
public function loadTargetBranch() { | public function loadTargetBranch() { | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |