public function process()
 {
     $repo_id = (int) $this->getParameter(0);
     $remote_server_id = (int) $this->getParameter(1);
     $this->dao->switchToGerrit($repo_id, $remote_server_id);
     $repository = $this->repository_factory->getRepositoryById($repo_id);
     if (!$repository) {
         $this->error('Unable to find repository, perhaps it was deleted in the mean time?');
         return;
     }
     try {
         $server = $this->server_factory->getServer($repository);
         $gerrit_template_id = $this->getParameter(2);
         $gerrit_project = $this->project_creator->createGerritProject($server, $repository, $gerrit_template_id);
         $this->project_creator->removeTemporaryDirectory();
         $this->project_creator->finalizeGerritProjectCreation($server, $repository, $gerrit_template_id);
         $this->dao->setGerritMigrationSuccess($repository->getId());
         $repository->setRemoteServerMigrationStatus(Git_Driver_Gerrit_ProjectCreatorStatus::DONE);
         $repository->getBackend()->updateRepoConf($repository);
         $this->done("Created project {$gerrit_project} on " . $server->getHost());
         return true;
     } catch (Git_Driver_Gerrit_ProjectCreator_ProjectAlreadyExistsException $e) {
         $this->logError($repository, "gerrit: ", "Gerrit failure: ", $e);
     } catch (Git_Driver_Gerrit_Exception $e) {
         $this->logError($repository, "gerrit: ", "Gerrit failure: ", $e);
     } catch (Git_Command_Exception $e) {
         $this->logError($repository, "gerrit: ", "Gerrit failure: ", $e);
     } catch (Exception $e) {
         $this->logError($repository, "", "An error occured while processing event: ", $e);
     }
 }
Exemplo n.º 2
0
 public function itThrowsAnExceptionIfProjectAlreadyExists()
 {
     stub($this->userfinder)->getUgroups($this->repository->getId(), Git::PERM_READ)->returns(array(ProjectUGroup::REGISTERED));
     stub($this->userfinder)->getUgroups($this->repository->getId(), Git::PERM_WRITE)->returns(array(ProjectUGroup::PROJECT_MEMBERS, 120));
     stub($this->userfinder)->getUgroups($this->repository->getId(), Git::PERM_WPLUS)->returns(array(ProjectUGroup::PROJECT_ADMIN));
     $driver = mock('Git_Driver_Gerrit');
     stub($driver)->doesTheProjectExist()->returns(true);
     $gerrit_driver_factory = stub('Git_Driver_Gerrit_GerritDriverFactory')->getDriver()->returns($driver);
     $project_creator = new Git_Driver_Gerrit_ProjectCreator($this->gerrit_tmpdir, $gerrit_driver_factory, $this->userfinder, $this->ugroup_manager, $this->membership_manager, $this->umbrella_manager, $this->template_factory, $this->template_processor);
     $this->expectException('Git_Driver_Gerrit_ProjectCreator_ProjectAlreadyExistsException');
     $project_creator->createGerritProject($this->server, $this->repository, $this->migrate_access_rights);
     $project_creator->finalizeGerritProjectCreation($this->server, $this->repository, $this->template_id);
 }