Exemplo n.º 1
0
 /**
  * This method allows one to save any repository attribues changes from the web interface.
  * @param <type> $repoId
  * @param <type> $repoAccess
  * @param <type> $repoDescription
  * @return <type>
  */
 public function save($projectId, $repoId, $repoAccess, $repoDescription, $pane)
 {
     $controller = $this->getController();
     if (empty($repoId)) {
         $this->addError('actions_params_error');
         $controller->redirect('/plugins/git/?action=index&group_id=' . $projectId);
         return false;
     }
     $repository = $this->factory->getRepositoryById($repoId);
     if (!$repository) {
         $this->addError('actions_repo_not_found');
         $controller->redirect('/plugins/git/?group_id=' . $projectId);
         return false;
     }
     if (empty($repoAccess) && empty($repoDescription)) {
         $this->addError('actions_params_error');
         $this->redirectToRepo($repository);
         return false;
     }
     if ($repoDescription) {
         if (strlen($repoDescription) > 1024) {
             $this->addError('actions_long_description');
         } else {
             $repository->setDescription($repoDescription);
             $this->history_dao->groupAddHistory("git_repo_update", $repository->getName() . ': update description', $repository->getProjectId());
         }
     }
     try {
         $repository->save();
         if (!empty($repoAccess)) {
             //TODO use Polymorphism to handle this
             if ($repository->getBackend() instanceof Git_Backend_Gitolite) {
                 $repository->getBackend()->savePermissions($repository, $repoAccess);
             } else {
                 if ($repository->getAccess() != $repoAccess) {
                     $this->git_system_event_manager->queueGitShellAccess($repository, $repoAccess);
                     $controller->addInfo($this->getText('actions_repo_access'));
                 }
             }
         }
         $this->git_system_event_manager->queueRepositoryUpdate($repository);
     } catch (GitDaoException $e) {
         $controller->addError($e->getMessage());
         $this->redirectToRepoManagement($projectId, $repoId, $pane);
         return false;
     }
     $controller->addInfo($this->getText('actions_save_repo_process'));
     $this->redirectToRepoManagement($projectId, $repoId, $pane);
     return;
 }
Exemplo n.º 2
0
 public function itCreatesRepositoryAccessEvent()
 {
     $repository = stub('GitRepository')->getId()->returns(54);
     expect($this->system_event_manager)->createEvent(SystemEvent_GIT_LEGACY_REPO_ACCESS::NAME, "54" . SystemEvent::PARAMETER_SEPARATOR . "private", SystemEvent::PRIORITY_HIGH, SystemEvent::OWNER_ROOT)->once();
     $this->git_system_event_manager->queueGitShellAccess($repository, 'private');
 }