示例#1
0
 /**
  * Builds the Gerrit Driver regarding the gerrit server version
  *
  * @param Git_RemoteServer_GerritServer $server The gerrit server
  *
  * @return Git_Driver_Gerrit
  */
 public function getDriver(Git_RemoteServer_GerritServer $server)
 {
     if ($server->getGerritVersion() === Git_RemoteServer_GerritServer::GERRIT_VERSION_2_8_PLUS) {
         include_once '/usr/share/php-guzzle/guzzle.phar';
         $class = 'Guzzle\\Http\\Client';
         return new Git_Driver_GerritREST(new $class('', array('ssl.certificate_authority' => 'system')), $this->logger);
     }
     return new Git_Driver_GerritLegacy(new Git_Driver_Gerrit_RemoteSSHCommand($this->logger), $this->logger);
 }
示例#2
0
 /**
  * Builds the Gerrit Driver regarding the gerrit server version
  *
  * @param Git_RemoteServer_GerritServer $server The gerrit server
  *
  * @return Git_Driver_Gerrit
  */
 public function getDriver(Git_RemoteServer_GerritServer $server)
 {
     include_once 'server.php';
     if (server_is_php_version_equal_or_greater_than_53() && $server->getGerritVersion() === Git_RemoteServer_GerritServer::GERRIT_VERSION_2_8_PLUS) {
         include_once '/usr/share/php-guzzle/guzzle.phar';
         $class = 'Guzzle\\Http\\Client';
         return new Git_Driver_GerritREST(new $class(), $this->logger);
     }
     return new Git_Driver_GerritLegacy(new Git_Driver_Gerrit_RemoteSSHCommand($this->logger), $this->logger);
 }
 private function cloneGerritProjectConfig(Git_RemoteServer_GerritServer $gerrit_server, $gerrit_project_url)
 {
     $git_exec = new Git_Exec($this->dir);
     if (!is_dir($this->dir)) {
         mkdir($this->dir);
         $git_exec->init();
         $git_exec->setLocalCommiter($gerrit_server->getLogin(), 'codendiadm@' . ForgeConfig::get('sys_default_domain'));
         $git_exec->remoteAdd($gerrit_project_url);
     }
     $git_exec->pullBranch('origin', 'refs/meta/config');
     $git_exec->checkoutBranch('FETCH_HEAD');
 }
 public function queueGerritReplicationKeyUpdate(Git_RemoteServer_GerritServer $server)
 {
     $this->system_event_manager->createEvent(SystemEvent_GIT_GERRIT_ADMIN_KEY_DUMP::NAME, $server->getId(), SystemEvent::PRIORITY_HIGH, SystemEvent::OWNER_APP);
 }
 /**
  *
  * @param Git_RemoteServer_GerritServer $server
  * @return bool
  */
 public function isServerUsed(Git_RemoteServer_GerritServer $server)
 {
     return $this->git_dao->isRemoteServerUsed($server->getId());
 }
示例#6
0
 /**
  * @param Git_RemoteServer_GerritServer        $server
  * @param Guzzle\Http\Message\RequestInterface $request
  *
  * @return Guzzle\Http\Message\Response
  */
 private function sendRequest(Git_RemoteServer_GerritServer $server, Guzzle\Http\Message\RequestInterface $request)
 {
     $request->setAuth($server->getLogin(), $server->getHTTPPassword(), 'Digest');
     return $request->send();
 }
示例#7
0
 public function itGivesTheReplicationKeyToProjectRequests()
 {
     $id = 1;
     $host = 'le_host';
     $http_port = '8080';
     $ssh_port = 'le_ssh_port';
     $login = '******';
     $identity_file = 'le_identity_file';
     $replication_key = '';
     $use_ssl = false;
     $gerrit_version = '2.5';
     $http_password = '******';
     $server = new Git_RemoteServer_GerritServer($id, $host, $ssh_port, $http_port, $login, $identity_file, $replication_key, $use_ssl, $gerrit_version, $http_password);
     $this->assertEqual($server->getReplicationKey('gerrit_project_name'), $replication_key);
 }
 public function __construct(Git_RemoteServer_GerritServer $server, $is_used)
 {
     $this->id = $server->getId();
     $this->host = $server->getHost();
     $this->http_port = $server->getHTTPPort();
     $this->ssh_port = $server->getSSHPort();
     $this->replication_key = $server->getReplicationKey();
     $this->use_ssl = $server->usesSSL();
     $this->login = $server->getLogin();
     $this->identity_file = $server->getIdentityFile();
     $this->use_gerrit_2_5 = $server->getGerritVersion() === Git_RemoteServer_GerritServer::DEFAULT_GERRIT_VERSION;
     $this->use_gerrit_2_8 = $server->getGerritVersion() !== Git_RemoteServer_GerritServer::DEFAULT_GERRIT_VERSION;
     $this->is_used = $is_used;
     $this->http_password = $server->getHTTPPassword();
 }
示例#9
0
 private function doesRemoteGerritProjectNeedDeleting(Git_RemoteServer_GerritServer $server)
 {
     if ($server->getId() != $this->repository->getRemoteServerId()) {
         return false;
     }
     if (!$this->repository->wasPreviouslyMigratedButNotDeleted()) {
         return false;
     }
     $driver = $this->getGerritDriverForRepository($this->repository);
     $project_name = $driver->getGerritProjectName($this->repository);
     try {
         if (!$driver->doesTheProjectExist($server, $project_name)) {
             return false;
         }
     } catch (Git_Driver_Gerrit_Exception $e) {
         return false;
     }
     return true;
 }
 public function itTriggersKeyUpdateEventOnSave()
 {
     $this->main_gerrit_server->setLogin('new_login');
     expect($this->system_event_manager)->queueGerritReplicationKeyUpdate($this->main_gerrit_server)->once();
     $this->factory->save($this->main_gerrit_server);
 }
 private function cacheGroupDefinitionForServer(Git_RemoteServer_GerritServer $server)
 {
     if (!isset($this->cache_groups[$server->getId()])) {
         $this->cache_groups[$server->getId()] = $this->driver_factory->getDriver($server)->getAllGroups($server);
     }
 }