コード例 #1
0
ファイル: GitActions.class.php プロジェクト: nickl-/tuleap
 public function cloneRepository($projectId, $forkName, $parentId)
 {
     $c = $this->getController();
     $projectId = intval($projectId);
     $parentId = intval($parentId);
     if (empty($projectId) || empty($forkName) || empty($parentId)) {
         $c->addError($this->getText('actions_params_error'));
         return false;
     }
     $parentRepo = new GitRepository();
     $parentRepo->setId($parentId);
     try {
         $parentRepo->load();
         // Disable possibility to delete gitolite repositories
         if ($parentRepo->getBackend() instanceof Git_Backend_Gitolite) {
             $c->addError($this->getText('disable_fork_gitolite'));
             $c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
         }
         if ($parentRepo->isNameValid($forkName) === false) {
             $c->addError($this->getText('actions_input_format_error', array($parentRepo->getBackend()->getAllowedCharsInNamePattern(), GitDao::REPO_NAME_MAX_LENGTH)));
             $c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
             return false;
         }
         if (!$parentRepo->isInitialized()) {
             $c->addError($this->getText('repo_not_initialized'));
             $c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
             return false;
         }
     } catch (GitDaoException $e) {
         $c->addError($e->getMessage());
         $c->redirect('/plugins/git/?action=index&group_id=' . $projectId);
         return false;
     }
     $this->systemEventManager->createEvent('GIT_REPO_CLONE', $projectId . SystemEvent::PARAMETER_SEPARATOR . $forkName . SystemEvent::PARAMETER_SEPARATOR . $parentId . SystemEvent::PARAMETER_SEPARATOR . $this->user->getId(), SystemEvent::PRIORITY_MEDIUM);
     $c->addInfo($this->getText('actions_create_repo_process'));
     $c->redirect('/plugins/git/index.php/' . $projectId . '/view/' . $parentId . '/');
     return;
 }
コード例 #2
0
ファイル: GitRepositoryTest.php プロジェクト: nterray/tuleap
 private function checkNameValidation(GitRepository $repo)
 {
     $this->assertFalse($repo->isNameValid(''));
     $this->assertFalse($repo->isNameValid('/'));
     $this->assertFalse($repo->isNameValid('/jambon'));
     $this->assertFalse($repo->isNameValid('jambon/'));
     $this->assertTrue($repo->isNameValid('jambon'));
     $this->assertTrue($repo->isNameValid('jambon.beurre'));
     $this->assertTrue($repo->isNameValid('jambon-beurre'));
     $this->assertTrue($repo->isNameValid('jambon_beurre'));
     $this->assertFalse($repo->isNameValid('jambon/.beurre'));
     $this->assertFalse($repo->isNameValid('jambon..beurre'));
     $this->assertFalse($repo->isNameValid('jambon...beurre'));
     $this->assertFalse($repo->isNameValid(str_pad('name_with_more_than_255_chars_', 256, '_')));
     $this->assertFalse($repo->isNameValid('repo.git'));
     $this->assertFalse($repo->isNameValid('u/toto'));
 }
コード例 #3
0
 private function isNamespaceValid(GitRepository $repository, $namespace)
 {
     if ($namespace) {
         $ns_chunk = explode('/', $namespace);
         foreach ($ns_chunk as $chunk) {
             if (!$repository->isNameValid($chunk)) {
                 throw new Exception($GLOBALS['Language']->getText('plugin_git', 'fork_repository_invalid_namespace'));
             }
         }
     }
     return true;
 }
コード例 #4
0
 private function isNamespaceValid(GitRepository $repository, $namespace)
 {
     if ($namespace) {
         $ns_chunk = explode('/', $namespace);
         foreach ($ns_chunk as $chunk) {
             if (!$repository->isNameValid($chunk)) {
                 $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_git', 'fork_repository_invalid_namespace'));
                 return false;
             }
         }
     }
     return true;
 }