public function getCircleCIGitHubRepositoryURI()
 {
     $repository = $this->getRepository();
     $commit_phid = $this->getPHID();
     $repository_phid = $repository->getPHID();
     if ($repository->isHosted()) {
         throw new Exception(pht('This commit ("%s") is associated with a hosted repository ' . '("%s"). Repositories must be imported from GitHub to be built ' . 'with CircleCI.', $commit_phid, $repository_phid));
     }
     $remote_uri = $repository->getRemoteURI();
     $path = HarbormasterCircleCIBuildStepImplementation::getGitHubPath($remote_uri);
     if (!$path) {
         throw new Exception(pht('This commit ("%s") is associated with a repository ("%s") that ' . 'with a remote URI ("%s") that does not appear to be hosted on ' . 'GitHub. Repositories must be hosted on GitHub to be built with ' . 'CircleCI.', $commit_phid, $repository_phid, $remote_uri));
     }
     return $remote_uri;
 }
Пример #2
0
 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;
 }